-
Notifications
You must be signed in to change notification settings - Fork 64
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
GitHasStagedChanges only considers modified files, not new/deleted/renamed #77
Comments
@andreasnilsen to not break anything, perhaps add an |
@devlead I understand your concern, but imho that name is a bit vague, it's not intuitive to me how it relates to/differs from Or maybe give it an optional flags enum for the places as an argument, which defaults to only modified files, i.e. current the functionality? |
I also ran into this today when pushing to my |
cake-contrib/Cake_Git#77 Since there are only new/deleted files in this commit, need to ignore this check for now, and add it back in afterwards.
(build) Running into issue with Cake.Git cake-contrib/Cake_Git#77 Since there are only new/deleted files in this commit, need to ignore this check for now, and add it back in afterwards.
Looking at the source code for LibGit2Sharp's RepositoryStatus, it seems that the "Staged" list only contains existing files that were modified, not files that were added, deleted or renamed. These are stored in separate lists.
https://github.com/libgit2/libgit2sharp/blob/f8e2d42ed9051fa5a5348c1a13d006f0cc069bc7/LibGit2Sharp/RepositoryStatus.cs#L42
The Cake.Git method GitAliases.Repository.GitHasStagedChanges only checks the RepositoryStatus.Staged list, not the NewInIndex, DeletedFromIndex, RenamedInIndex.
Cake_Git/src/Cake.Git/GitAliases.Repository.cs
Lines 101 to 121 in ad0b56e
So if your changes only contain new files/deleted files/renamed files,
GitHasStagedChanges
will returnfalse
.I'm not an expert on Git terminology, but I believe "staged" means any changes staged for commit, not just modified files?
If so, I guess it's a matter of discussion where the error lies, LibGit2Sharp's naming of the Staged-list is maybe a bit unfortunate, but I also guess that Cake.Git is consuming the RepositoryStatus "API" wrongly?
The text was updated successfully, but these errors were encountered: