Skip to content

Commit

Permalink
Fix git merge editor for renames (#209542)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexr00 authored Apr 8, 2024
1 parent 09734e0 commit a1815b9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions extensions/git/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,10 +711,13 @@ export class CommandCenter {
}

try {
const [head, rebaseOrMergeHead] = await Promise.all([
const [head, rebaseOrMergeHead, diffBetween] = await Promise.all([
repo.getCommit('HEAD'),
isRebasing ? repo.getCommit('REBASE_HEAD') : repo.getCommit('MERGE_HEAD')
isRebasing ? repo.getCommit('REBASE_HEAD') : repo.getCommit('MERGE_HEAD'),
await repo.diffBetween(isRebasing ? 'REBASE_HEAD' : 'MERGE_HEAD', 'HEAD')
]);
const diffFile = diffBetween?.find(diff => diff.uri.fsPath === uri.fsPath);

// ours (current branch and commit)
current.detail = head.refNames.map(s => s.replace(/^HEAD ->/, '')).join(', ');
current.description = '$(git-commit) ' + head.hash.substring(0, 7);
Expand All @@ -723,7 +726,11 @@ export class CommandCenter {
// theirs
incoming.detail = rebaseOrMergeHead.refNames.join(', ');
incoming.description = '$(git-commit) ' + rebaseOrMergeHead.hash.substring(0, 7);
incoming.uri = toGitUri(uri, rebaseOrMergeHead.hash);
if (diffFile) {
incoming.uri = toGitUri(diffFile.originalUri, rebaseOrMergeHead.hash);
} else {
incoming.uri = toGitUri(uri, rebaseOrMergeHead.hash);
}

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

0 comments on commit a1815b9

Please sign in to comment.