Skip to content

Commit 7d90d7e

Browse files
committed
Fixes #3050 for real - handles renamed file in working tree
1 parent 3939786 commit 7d90d7e

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/env/node/git/localGitProvider.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3874,12 +3874,26 @@ export class LocalGitProvider implements GitProvider, Disposable {
38743874
range = new Range(range.end, range.start);
38753875
}
38763876

3877-
const data = await this.git.log__file(root, relativePath, ref, {
3877+
let data = await this.git.log__file(root, relativePath, ref, {
38783878
ordering: configuration.get('advanced.commitOrdering'),
38793879
...options,
38803880
startLine: range == null ? undefined : range.start.line + 1,
38813881
endLine: range == null ? undefined : range.end.line + 1,
38823882
});
3883+
3884+
// If we didn't find any history from the working tree, check to see if the file was renamed
3885+
if (!data && ref == null) {
3886+
const status = await this.getStatusForFile(root, relativePath);
3887+
if (status?.originalPath != null) {
3888+
data = await this.git.log__file(root, status.originalPath, ref, {
3889+
ordering: configuration.get('advanced.commitOrdering'),
3890+
...options,
3891+
startLine: range == null ? undefined : range.start.line + 1,
3892+
endLine: range == null ? undefined : range.end.line + 1,
3893+
});
3894+
}
3895+
}
3896+
38833897
const log = parseGitLog(
38843898
this.container,
38853899
data,
@@ -5030,18 +5044,9 @@ export class LocalGitProvider implements GitProvider, Disposable {
50305044

50315045
continue;
50325046
}
5033-
5034-
return undefined;
50355047
}
50365048

5037-
if (ref != null) return undefined;
5038-
5039-
// If we still didn't find anything then check if we've been renamed first
5040-
const status = await this.getStatusForFile(repoPath, relativePath);
5041-
if (status?.originalPath != null) {
5042-
tracked = Boolean(await this.git.ls_files(repoPath, status.originalPath, { ref: 'HEAD' }));
5043-
if (!tracked) return undefined;
5044-
}
5049+
return undefined;
50455050
}
50465051

50475052
return [relativePath, repoPath];

0 commit comments

Comments
 (0)