Fix git merge editor for renames (#209542)

This commit is contained in:
Alex Ross 2024-04-08 23:34:48 +02:00 committed by GitHub
parent 09734e0145
commit a1815b994a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);
@ -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