commit 1570c7d00153181729832ad6f90466fe7d29b858
parent 8648e2ab324a4e59ae61f47df37cb4319bcdd823
Author: Leah (ctucx) <leah@ctu.cx>
Date: Thu, 18 Mar 2021 13:27:33 +0100
parent 8648e2ab324a4e59ae61f47df37cb4319bcdd823
Author: Leah (ctucx) <leah@ctu.cx>
Date: Thu, 18 Mar 2021 13:27:33 +0100
fix
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/nimgit/blob.nim b/nimgit/blob.nim @@ -16,8 +16,10 @@ proc id* (blob: GitBlob): GitObjectId = git_blob_id(blob) proc shortId* (blob: GitBlob): string = cast[GitObject](blob).shortId() -proc content* (blob: GitBlob): string = cast[string](git_blob_rawcontent(blob)) - proc size* (blob: GitBlob): int = cast[int](git_blob_rawsize(blob)) +proc content* (blob: GitBlob): string = + result = newString(blob.size) + copyMem(result.cstring, git_blob_rawcontent(blob), blob.size) + proc isBinary* (blob: GitBlob): bool = cast[bool](git_blob_is_binary(blob))
diff --git a/nimgit/tree.nim b/nimgit/tree.nim @@ -22,7 +22,7 @@ proc entry* (tree: GitTree, id: int): GitTreeEntry = git_tree_entry_byindex(tree proc entry* (tree: GitTree, id: GitObjectId): GitTreeEntry = git_tree_entry_byid(tree, id) -proc entry* (tree: GitTree, name: string): GitTreeEntry = git_tree_entry_byname(tree, cstring(name)) +#proc entry* (tree: GitTree, name: string): GitTreeEntry = git_tree_entry_byname(tree, cstring(name)) proc entry* (tree: GitTree, path: string): GitTreeEntry = let error = git_tree_entry_bypath(addr result, tree, cstring(path)).getResultCode
diff --git a/nimgit/treeEntry.nim b/nimgit/treeEntry.nim @@ -11,9 +11,12 @@ proc mode* (entry: GitTreeEntry): int = cast[int](git_tree_entry_filemode(entry) proc modeStr* (entry: GitTreeEntry): string = filemodeStr(entry.mode) -proc getObject* (repo: GitRepository, entry: GitTreeEntry): GitObject = - let error = git_tree_entry_to_object(addr result, repo, entry) +proc getObject* (repo: GitRepository, entry: GitTreeEntry): GitBlob = + var obj: GitObject + let error = git_tree_entry_to_object(addr obj, repo, entry) if error != 0: free(result) raise newException(CatchableError, "Cannot convert tree-entry into object: " & $error.getResultCode) + + result = cast[GitBlob](obj)+ \ No newline at end of file