Skip to content

Commit a1815b9

Browse files
authored
Fix git merge editor for renames (microsoft#209542)
1 parent 09734e0 commit a1815b9

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

extensions/git/src/commands.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,10 +711,13 @@ export class CommandCenter {
711711
}
712712

713713
try {
714-
const [head, rebaseOrMergeHead] = await Promise.all([
714+
const [head, rebaseOrMergeHead, diffBetween] = await Promise.all([
715715
repo.getCommit('HEAD'),
716-
isRebasing ? repo.getCommit('REBASE_HEAD') : repo.getCommit('MERGE_HEAD')
716+
isRebasing ? repo.getCommit('REBASE_HEAD') : repo.getCommit('MERGE_HEAD'),
717+
await repo.diffBetween(isRebasing ? 'REBASE_HEAD' : 'MERGE_HEAD', 'HEAD')
717718
]);
719+
const diffFile = diffBetween?.find(diff => diff.uri.fsPath === uri.fsPath);
720+
718721
// ours (current branch and commit)
719722
current.detail = head.refNames.map(s => s.replace(/^HEAD ->/, '')).join(', ');
720723
current.description = '$(git-commit) ' + head.hash.substring(0, 7);
@@ -723,7 +726,11 @@ export class CommandCenter {
723726
// theirs
724727
incoming.detail = rebaseOrMergeHead.refNames.join(', ');
725728
incoming.description = '$(git-commit) ' + rebaseOrMergeHead.hash.substring(0, 7);
726-
incoming.uri = toGitUri(uri, rebaseOrMergeHead.hash);
729+
if (diffFile) {
730+
incoming.uri = toGitUri(diffFile.originalUri, rebaseOrMergeHead.hash);
731+
} else {
732+
incoming.uri = toGitUri(uri, rebaseOrMergeHead.hash);
733+
}
727734

728735
} catch (error) {
729736
// not so bad, can continue with just uris

0 commit comments

Comments
 (0)