Skip to content

Commit b97d0a2

Browse files
authored
Git - include changes from both commits in the range (microsoft#223050)
1 parent 3eeb527 commit b97d0a2

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

extensions/git/src/commands.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4204,21 +4204,24 @@ export class CommandCenter {
42044204
}
42054205
}
42064206

4207-
const historyItemId = historyItem1.id;
4208-
const historyItemParentId = historyItem2 ? historyItem2.id :
4209-
historyItem1.parentIds.length > 0 ? historyItem1.parentIds[0] : `${historyItemId}^`;
4207+
let title: string | undefined;
4208+
let historyItemParentId: string | undefined;
42104209

4211-
let title = '';
4210+
// If historyItem2 is not provided, we are viewing a single commit. If historyItem2 is
4211+
// provided, we are viewing a range and we have to include both start and end commits.
4212+
// TODO@lszomoru - handle the case when historyItem2 is the first commit in the repository
42124213
if (!historyItem2) {
4213-
const commit = await repository.getCommit(historyItemId);
4214-
title = `${historyItemId.substring(0, 8)} - ${commit.message}`;
4214+
const commit = await repository.getCommit(historyItem1.id);
4215+
title = `${historyItem1.id.substring(0, 8)} - ${commit.message}`;
4216+
historyItemParentId = historyItem1.parentIds.length > 0 ? historyItem1.parentIds[0] : `${historyItem1.id}^`;
42154217
} else {
4216-
title = l10n.t('All Changes ({0} ↔ {1})', historyItemParentId.substring(0, 8), historyItemId.substring(0, 8));
4218+
title = l10n.t('All Changes ({0} ↔ {1})', historyItem2.id.substring(0, 8), historyItem1.id.substring(0, 8));
4219+
historyItemParentId = historyItem2.parentIds.length > 0 ? historyItem2.parentIds[0] : `${historyItem2.id}^`;
42174220
}
42184221

4219-
const multiDiffSourceUri = toGitUri(Uri.file(repository.root), `${historyItemParentId}..${historyItemId}`, { scheme: 'git-commit', });
4222+
const multiDiffSourceUri = toGitUri(Uri.file(repository.root), `${historyItemParentId}..${historyItem1.id}`, { scheme: 'git-commit', });
42204223

4221-
await this._viewChanges(repository, historyItemId, historyItemParentId, multiDiffSourceUri, title);
4224+
await this._viewChanges(repository, historyItem1.id, historyItemParentId, multiDiffSourceUri, title);
42224225
}
42234226

42244227
@command('git.viewAllChanges', { repository: true })

0 commit comments

Comments
 (0)