What's wrong
GitCli.ListPendingChanges (ProjectDirector/GitCli.cs, ~line 219) parses git status --porcelain -z. It skips a rename's extra source-path record only when the first status character is R or C:
// A rename or copy is recorded against the index, in the first status character.
if (entry[0] is 'R' or 'C')
{
++i;
}
Porcelain v1 can also report a rename in the second (worktree) character. That happens when a file added with intent-to-add (git add -N) is detected as a rename of a deleted tracked file. Git then writes R new.txt\0ab cd.txt\0. Because entry[1] isn't checked, the source record ab cd.txt is parsed as its own entry: status ab, separator , path cd.txt.
Failure scenario
Reproduced with a scratch test:
- Commit
ab cd.txt.
- Delete it and create
new.txt with the same content.
- Run
git add -N new.txt.
The raw status output is R new.txt|ab cd.txt|, and ListPendingChanges returns new.txt ; cd.txt. The commit confirmation then shows a file cd.txt that doesn't exist, and the change count is wrong. The method's remarks and CLAUDE.md both say renames with spaces are handled.
Suggested fix
if (entry[0] is 'R' or 'C' || entry[1] is 'R' or 'C')
{
++i;
}
Update the comment to match, and add a test for the worktree-column rename.
What's wrong
GitCli.ListPendingChanges(ProjectDirector/GitCli.cs, ~line 219) parsesgit status --porcelain -z. It skips a rename's extra source-path record only when the first status character isRorC:Porcelain v1 can also report a rename in the second (worktree) character. That happens when a file added with intent-to-add (
git add -N) is detected as a rename of a deleted tracked file. Git then writesR new.txt\0ab cd.txt\0. Becauseentry[1]isn't checked, the source recordab cd.txtis parsed as its own entry: statusab, separator, pathcd.txt.Failure scenario
Reproduced with a scratch test:
ab cd.txt.new.txtwith the same content.git add -N new.txt.The raw status output is
R new.txt|ab cd.txt|, andListPendingChangesreturnsnew.txt ; cd.txt. The commit confirmation then shows a filecd.txtthat doesn't exist, and the change count is wrong. The method's remarks and CLAUDE.md both say renames with spaces are handled.Suggested fix
Update the comment to match, and add a test for the worktree-column rename.