pygit2 icon indicating copy to clipboard operation
pygit2 copied to clipboard

Missing binding for libgit2 git_repository_hashfile

Open muhqu opened this issue 2 years ago • 8 comments

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.

muhqu avatar Feb 13 '23 10:02 muhqu

@jdavid Thanks for merging my PR #1190 🙏

…do you plan to make a release to ship this change in the coming days?

muhqu avatar Feb 14 '23 07:02 muhqu

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…

muhqu avatar Feb 14 '23 08:02 muhqu

No idea, that's probably a question for the libgit2 developers.

About the release I first want to at least review PR #1191

jdavid avatar Feb 14 '23 17:02 jdavid

Thanks! I've created https://github.com/libgit2/libgit2/issues/6481 to seek for help from libgit2 developers.

muhqu avatar Feb 15 '23 10:02 muhqu

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 avatar Feb 24 '23 17:02 jdavid

@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

muhqu avatar Feb 25 '23 15:02 muhqu

I'll see if I find time to look into the issue next week.

muhqu avatar Feb 25 '23 15:02 muhqu

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).

jdavid avatar Mar 01 '23 11:03 jdavid