Skip to content

Conversation

@lszomoru
Copy link
Member

Related #286776

Copilot AI review requested due to automatic review settings January 11, 2026 17:42
@lszomoru lszomoru enabled auto-merge (squash) January 11, 2026 17:42
@lszomoru lszomoru self-assigned this Jan 11, 2026
@lszomoru lszomoru added the git GIT issues label Jan 11, 2026
@lszomoru lszomoru added this to the January 2026 milestone Jan 11, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in the git extension's parsing of git diff raw output to correctly handle renamed files. The issue occurs when parsing --numstat output with the -z flag, where renamed files have an empty filePath followed by null-terminated old and new paths.

Changes:

  • Modified the parseGitChangesRaw function to detect when filePath is empty in --numstat output
  • Added logic to skip the old path and use the new path for mapping numstat data to renamed files

Comment on lines +1149 to +1152
// old path and use the new path for the stats key.
index++;

const renamePath = segments[index++];
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code should validate that renamePath exists before using it. If segments[index] is undefined (e.g., due to malformed git output), this will cause path.isAbsolute(renamePath) to throw an error or create an invalid path. Consider adding a check similar to the one used for renamed files in the --raw parsing section (lines 1123-1129).

Suggested change
// old path and use the new path for the stats key.
index++;
const renamePath = segments[index++];
// old path and use the new path for the stats key.
if (index >= segments.length) {
break;
}
index++;
if (index >= segments.length) {
break;
}
const renamePath = segments[index++];
if (!renamePath) {
break;
}

Copilot uses AI. Check for mistakes.
@lszomoru lszomoru merged commit 2c1a2ee into main Jan 11, 2026
27 of 28 checks passed
@lszomoru lszomoru deleted the lszomoru/independent-bird branch January 11, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

git GIT issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants