mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-23 19:59:37 +00:00
fix: resolve renamed paths on merge editor (#254677)
This commit is contained in:
committed by
GitHub
parent
a1d4cfa3d8
commit
62ff0cceb4
@@ -862,23 +862,32 @@ export class CommandCenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const [head, rebaseOrMergeHead, diffBetween] = await Promise.all([
|
const [head, rebaseOrMergeHead, oursDiff, theirsDiff] = await Promise.all([
|
||||||
repo.getCommit('HEAD'),
|
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')
|
await repo.diffBetween(isRebasing ? 'REBASE_HEAD' : 'MERGE_HEAD', 'HEAD'),
|
||||||
|
await repo.diffBetween('HEAD', isRebasing ? 'REBASE_HEAD' : 'MERGE_HEAD')
|
||||||
]);
|
]);
|
||||||
const diffFile = diffBetween?.find(diff => diff.uri.fsPath === uri.fsPath);
|
|
||||||
|
const oursDiffFile = oursDiff?.find(diff => diff.uri.fsPath === uri.fsPath);
|
||||||
|
const theirsDiffFile = theirsDiff?.find(diff => diff.uri.fsPath === uri.fsPath);
|
||||||
|
|
||||||
// ours (current branch and commit)
|
// ours (current branch and commit)
|
||||||
current.detail = head.refNames.map(s => s.replace(/^HEAD ->/, '')).join(', ');
|
current.detail = head.refNames.map(s => s.replace(/^HEAD ->/, '')).join(', ');
|
||||||
current.description = '$(git-commit) ' + head.hash.substring(0, 7);
|
current.description = '$(git-commit) ' + head.hash.substring(0, 7);
|
||||||
|
if (theirsDiffFile) {
|
||||||
|
// use the original uri in case the file was renamed by theirs
|
||||||
|
current.uri = toGitUri(theirsDiffFile.originalUri, head.hash);
|
||||||
|
} else {
|
||||||
current.uri = toGitUri(uri, head.hash);
|
current.uri = toGitUri(uri, head.hash);
|
||||||
|
}
|
||||||
|
|
||||||
// theirs
|
// theirs
|
||||||
incoming.detail = rebaseOrMergeHead.refNames.join(', ');
|
incoming.detail = rebaseOrMergeHead.refNames.join(', ');
|
||||||
incoming.description = '$(git-commit) ' + rebaseOrMergeHead.hash.substring(0, 7);
|
incoming.description = '$(git-commit) ' + rebaseOrMergeHead.hash.substring(0, 7);
|
||||||
if (diffFile) {
|
if (oursDiffFile) {
|
||||||
incoming.uri = toGitUri(diffFile.originalUri, rebaseOrMergeHead.hash);
|
// use the original uri in case the file was renamed by ours
|
||||||
|
incoming.uri = toGitUri(oursDiffFile.originalUri, rebaseOrMergeHead.hash);
|
||||||
} else {
|
} else {
|
||||||
incoming.uri = toGitUri(uri, rebaseOrMergeHead.hash);
|
incoming.uri = toGitUri(uri, rebaseOrMergeHead.hash);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user