Skip to content

Commit 8269872

Browse files
committed
Improves line diff tracking
- Better handling of renames - Starts at HEAD when there are no working changes
1 parent 28e70cd commit 8269872

File tree

1 file changed

+5
-4
lines changed
  • src/env/node/git/sub-providers

1 file changed

+5
-4
lines changed

src/env/node/git/sub-providers/diff.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,10 +576,6 @@ export class DiffGitSubProvider implements GitDiffSubProvider {
576576
currentPath = relativePath;
577577
rev = '';
578578
}
579-
} else if (!skipFirstRev) {
580-
currentSha = '';
581-
currentPath = relativePath;
582-
rev = '';
583579
}
584580
} else if (!skipFirstRev) {
585581
currentSha = rev;
@@ -635,6 +631,11 @@ export class DiffGitSubProvider implements GitDiffSubProvider {
635631
for (const commit of parser.parse(result.stdout)) {
636632
const path = relativePath;
637633
file = commit.files.find(f => f.path === path || f.originalPath === path);
634+
// If we couldn't find the file, but there is only one file in the commit, use that one and assume the filename changed
635+
if (file == null && commit.files.length === 1) {
636+
file = commit.files[0];
637+
relativePath = file.path;
638+
}
638639
// Keep track of the file changing paths
639640
if (file?.originalPath && file.originalPath !== relativePath) {
640641
relativePath = file.originalPath;

0 commit comments

Comments
 (0)