Closed highfly22 closed 10 years ago
Hi, according to http://simplegit.googlecode.com/git-history/8e38c94c332f9fae1e9d85fcac24ead72ad3b351/group__git__odb.html#gae216becda5d6274da15193b0c34e2dce, git_odb_exists returns "true" when the object is found, which indicates we should be using != 0
here.
It seems there is some mismatch.
I have tested this function. The function behaviors like this document http://libgit2.github.com/libgit2/#HEAD/group/odb/git_odb_exists
And the same as https://code.google.com/p/simplegit/source/browse/include/git2/odb.h I also found the same comment in the hlibgit2-0.18.0.12.
Looking at the source code, it most definitely is returning true
; and on Windows at least, true is defined to be the number 1.
I am confused now. The source code of libgit2 should return 1 when object exists. But I run the following code
withRepository' L.lgFactory (RepositoryOptions "test-repo" True True) $ do
oid <- parseOid "bc7774a7b18deb1d7bd0212d34246a9b1260ae17"
e1 <- existsObject oid
liftIO $ print e1
blob <- lookupBlob (Tagged oid)
case blobContents blob of
(BlobString s) -> liftIO $ print $ decodeUtf8 s
It always gives the opposite result in my Debian Linux PC. The object is put by the command "echo -n 'hello world!' | git hash-object -w --stdin"
If the return value is -1, we should also check the errno to see why. It may be failing for another reason altogether.
...nd.