diff --git a/extensions/git/src/historyProvider.ts b/extensions/git/src/historyProvider.ts index df588388925..d3a64bb4bb5 100644 --- a/extensions/git/src/historyProvider.ts +++ b/extensions/git/src/historyProvider.ts @@ -102,13 +102,19 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec } async provideHistoryItemChanges(historyItemId: string): Promise { - const [ref1, ref2] = historyItemId.includes('..') - ? historyItemId.split('..') - : [`${historyItemId}^`, historyItemId]; + // The "All Changes" history item uses a special id + // which is a commit range instead of a single commit id + let [originalRef, modifiedRef] = historyItemId.includes('..') + ? historyItemId.split('..') : [undefined, historyItemId]; + + if (!originalRef) { + const commit = await this.repository.getCommit(modifiedRef); + originalRef = commit.parents.length > 0 ? commit.parents[0] : `${modifiedRef}^`; + } const historyItemChangesUri: Uri[] = []; const historyItemChanges: SourceControlHistoryItemChange[] = []; - const changes = await this.repository.diffBetween(ref1, ref2); + const changes = await this.repository.diffBetween(originalRef, modifiedRef); for (const change of changes) { const historyItemUri = change.uri.with({ @@ -118,8 +124,8 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec // History item change historyItemChanges.push({ uri: historyItemUri, - originalUri: toGitUri(change.originalUri, ref1), - modifiedUri: toGitUri(change.originalUri, ref2), + originalUri: toGitUri(change.originalUri, originalRef), + modifiedUri: toGitUri(change.originalUri, modifiedRef), renameUri: change.renameUri, });