pygit2
pygit2 copied to clipboard
Missing binding for libgit2 git_repository_hashfile
While there is pygit2.hashfile which is a binding for libgit2 git_odb_hashfile, there appears to be no binding for git_repository_hashfile.
The difference is that git_repository_hashfile calculates the file hash using repository filtering rules (e.g. crlf filters), while git_odb_hashfile doesn't apply any filtering rules.
~Would it be possible to add hashfile method to pygit2.Repository which maps to git_repository_hashfile?~
Here is a PR that adds hashfile(path) method to pygit2.Repository class.
@jdavid Thanks for merging my PR #1190 🙏
…do you plan to make a release to ship this change in the coming days?
Also … any idea why git_repository_hashfile is implemented to error when core.safecrlf is true and a files line endings are not correct? …see libgit2 API docs:
[…] if the repository has core.safecrlf set to fail and the filtering triggers that failure, then this function will return an error and not calculate the hash of the file.
I'm just wondering, as the git command git hash-object does not behave the same in this case, it will always return a hash while taking the crlf filtering into account…
No idea, that's probably a question for the libgit2 developers.
About the release I first want to at least review PR #1191
Thanks! I've created https://github.com/libgit2/libgit2/issues/6481 to seek for help from libgit2 developers.
I was going to make the release when I saw that tests fail in AppVeyor. It's the tests of the hashfile function, could you have a look? https://ci.appveyor.com/project/jdavid/pygit2/builds/46329622/job/iv77sk6d184mg3ep
@jdavid Oh no, I'm sorry for that... I've spent some time today to looks into it, but I have not built on windows for quite some time and so I'm still struggling to get a successful build running... 😞
I'm totally fine if you simply revert my merged PR to get the release out. And we can look into the issue in a new PR that again reverts the revert... does that make sense? 🤔 https://github.com/libgit2/pygit2/pull/1194
I'll see if I find time to look into the issue next week.
The release can wait a little bit.
There's a new version of libgit2, so I'll try to upgrade for the next release (though first https://github.com/libgit2/libgit2/issues/6519 has to be fixed).