-
Notifications
You must be signed in to change notification settings - Fork 899
Can't commit on a bare repository #692
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
Conversation
@mumitroller Bam! It's a bug. Very nice catch! I think that this check is the root cause of the issue. We should always update Would you feel like sending a Pull Request to fix this? We'd happily support you! |
@nulltoken I have zero knowledge of reflogs so I dont know how to fix the problem properly. The only solution that I can imagine now is just to remove these lines. |
@mumitroller Actually, my previous idea was unnecessarily complex. Because of some recent work at the libgit2 level, your proposal is enough to fix this issue. As such, I've granted you authorship of the commit above. @carlosmn While investigating this, I've discovered something weird (see the commented out lines in the test). Shouldn't libgit2/libgit2#2194 guard us against this? |
@mumitroller BTW, that was an awesomely crafted failing test! ✨ |
The fixes from libgit2 should indeed handle this correctly. I'm going to take a look. |
@nulltoken Thank you! |
|
||
// TODO: Uncomment these lines once this is handled at the libgit2 level | ||
//Assert.Equal(0, repo.Refs.Log("refs/heads/master").Count()); | ||
//Assert.Equal(0, repo.Refs.Log("HEAD").Count()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Further up, we set the workdir, which means this is no longer a bare repository, so the default is to log updates, so the right number here is 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duh. You're right. I forgot that git_repository_set_workdir()
was tweaking the is_bare
bit. Thanks for your 👀
I'm going to drop the comments and give LogCommit()
is a less terrible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carlosmn, @nulltoken Just for clarity - we set workdir only for this session, after closing the repository still remain bare. Hint for RepositoryOptions.WorkingDirectoryPath
says:
...combined with IndexPath, would allow to work against a bare repository as it was a standard one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The repository by itself is bare, but you've made your instance non-bare by giving it the workdir, which is what's missing in a bare repo.
@mumitroller It's merged. Thanks a lot for this perfect report! |
Could somebody review whether the following test case correct?