From 70ebec7b81a57211b50bc02a4fd6a69d0cf39a1d Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sun, 16 Sep 2018 03:27:55 -0400 Subject: [PATCH] Fixes issues showing uncommitted and staged content --- src/commands/diffWith.ts | 4 ++-- src/git/gitService.ts | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/commands/diffWith.ts b/src/commands/diffWith.ts index 54e57ff..9ad4c5f 100644 --- a/src/commands/diffWith.ts +++ b/src/commands/diffWith.ts @@ -113,8 +113,8 @@ export class DiffWithCommand extends ActiveEditorCommand { } const [lhs, rhs] = await Promise.all([ - Container.git.getVersionedFile(args.repoPath, args.lhs.uri.fsPath, args.lhs.sha), - Container.git.getVersionedFile(args.repoPath, args.rhs.uri.fsPath, args.rhs.sha) + Container.git.getVersionedUri(args.repoPath, args.lhs.uri.fsPath, args.lhs.sha), + Container.git.getVersionedUri(args.repoPath, args.rhs.uri.fsPath, args.rhs.sha) ]); let rhsSuffix = GitService.shortenSha(rhsSha, { uncommitted: 'working tree' }) || ''; diff --git a/src/git/gitService.ts b/src/git/gitService.ts index fd3f9e0..68533ff 100644 --- a/src/git/gitService.ts +++ b/src/git/gitService.ts @@ -1677,7 +1677,7 @@ export class GitService implements Disposable { return GitTreeParser.parse(data) || []; } - async getVersionedFile( + async getVersionedUri( repoPath: string | undefined, fileName: string, ref: string | undefined @@ -1692,6 +1692,16 @@ export class GitService implements Disposable { return undefined; } + if (Git.isStagedUncommitted(ref)) { + const path = paths.resolve(repoPath || '', fileName); + return Uri.parse( + `git:${path}?${JSON.stringify({ + path: path, + ref: '~' + })}` + ); + } + return GitUri.toRevisionUri(ref, fileName, repoPath!); }