Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing binding for libgit2 git_repository_hashfile #1189

Open
muhqu opened this issue Feb 13, 2023 · 8 comments
Open

Missing binding for libgit2 git_repository_hashfile #1189

muhqu opened this issue Feb 13, 2023 · 8 comments

Comments

@muhqu
Copy link
Contributor

muhqu commented Feb 13, 2023

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
Copy link
Contributor Author

muhqu commented Feb 14, 2023

@jdavid Thanks for merging my PR #1190 🙏

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

@muhqu
Copy link
Contributor Author

muhqu commented Feb 14, 2023

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…

@jdavid
Copy link
Member

jdavid commented Feb 14, 2023

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

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

@muhqu
Copy link
Contributor Author

muhqu commented Feb 15, 2023

Thanks! I've created libgit2/libgit2#6481 to seek for help from libgit2 developers.

@jdavid
Copy link
Member

jdavid commented Feb 24, 2023

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

@muhqu
Copy link
Contributor Author

muhqu commented Feb 25, 2023

@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? 🤔 #1194

@muhqu
Copy link
Contributor Author

muhqu commented Feb 25, 2023

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

@jdavid
Copy link
Member

jdavid commented Mar 1, 2023

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 libgit2/libgit2#6519 has to be fixed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants