libgit2 / pygit2

Python bindings for libgit2
https://www.pygit2.org/
Other
1.61k stars 385 forks source link

flaky repo.reset() behavior #1059

Open cjerdonek opened 3 years ago

cjerdonek commented 3 years ago

This issue is about repo.reset() not seeming to work reliably 100% of the time.

I have some CI tests that modify a file in a non-bare repo, commit the change to a branch, and then call repo.reset() with GIT_RESET_HARD to restore to a different commit. After calling reset, to confirm that the reset was successful, the test creates a new Repository object and checks the repository's status using repo.status(). Occasionally (but very rarely), the status check comes back showing the original file still as WT_MODIFIED. A subsequent call to repo.diff() confirms the difference in the file. Is there something pygit2 is or isn't doing that could cause reset() to behave flakily like this? Or is libgit2 the more likely culprit?

This is using pygit2 1.2.0. I can try upgrading, but is there a reason to think this would be fixed in a newer version (e.g. a known issue that was fixed)? I haven't found anything like this in pygit2 or libgit2's issue tracker or release notes.

cjerdonek commented 3 years ago

I haven't found anything like this in pygit2 or libgit2's issue tracker or release notes.

It's conceivable this issue is due to the following libgit2 issue, which was resolved in libgit2 1.1.0: https://github.com/libgit2/libgit2/pull/5515 (I don't know if repo.reset() uses the same code path as that issue.) I was using pygit2 1.2.0, which uses 1.0.0. I'll see if this issue goes away after upgrading to pygit2 1.4.0. That's the first pygit2 release to use libgit2 1.1.0: https://github.com/libgit2/pygit2/blob/master/CHANGELOG.rst#140-2020-11-06