diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 173696967fd..3e1bbbd4da6 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -2334,6 +2334,10 @@ export class CommandCenter { @command('git.openDiff', { repository: false }) async openDiff(uri: Uri, hash: string) { + if (hash === '~') { + return commands.executeCommand('vscode.diff', toGitUri(uri, hash), toGitUri(uri, `HEAD`)); + } + return commands.executeCommand('vscode.diff', toGitUri(uri, hash), toGitUri(uri, `${hash}^`)); } diff --git a/extensions/git/src/timelineProvider.ts b/extensions/git/src/timelineProvider.ts index ebb6b2efe0b..cc420768ac9 100644 --- a/extensions/git/src/timelineProvider.ts +++ b/extensions/git/src/timelineProvider.ts @@ -60,7 +60,7 @@ export class GitTimelineProvider implements TimelineProvider { console.log(`GitTimelineProvider.provideTimeline: commits=${commits.length}`); - return commits.map(c => { + const items = commits.map(c => { let message = c.message; const index = message.indexOf('\n'); @@ -82,6 +82,26 @@ export class GitTimelineProvider implements TimelineProvider { } }; }); + + const index = repo.indexGroup.resourceStates.find(r => r.resourceUri.fsPath === uri.fsPath); + if (index) { + items.push({ + id: '~', + // TODO: Fix the date + date: Date.now(), + iconPath: new ThemeIcon('git-commit'), + label: 'Staged Changes', + description: '', + detail: '', + command: { + title: 'Open Diff', + command: 'git.openDiff', + arguments: [uri, '~'] + } + }); + } + + return items; } @debounce(500)