From 2bdccf5cf1cbc4963a4acdb62fb8df6d4a09391f Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Fri, 31 Jul 2020 02:44:15 -0400 Subject: [PATCH] Fixes diff with added files --- src/commands/diffWith.ts | 6 +++++- src/git/gitService.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/commands/diffWith.ts b/src/commands/diffWith.ts index 710302e..ac1b59b 100644 --- a/src/commands/diffWith.ts +++ b/src/commands/diffWith.ts @@ -103,11 +103,15 @@ export class DiffWithCommand extends Command { args.rhs.uri.fsPath, args.rhs.sha, ); - if (status != null && status.status === 'D') { + if (status?.status === 'D') { args.rhs.sha = GitRevision.deletedOrMissing; } else { rhsSha = args.rhs.sha; } + + if (status?.status === 'A' && args.lhs.sha.endsWith('^')) { + args.lhs.sha = GitRevision.deletedOrMissing; + } } const [lhs, rhs] = await Promise.all([ diff --git a/src/git/gitService.ts b/src/git/gitService.ts index ffc47d2..9d668bf 100644 --- a/src/git/gitService.ts +++ b/src/git/gitService.ts @@ -3161,7 +3161,7 @@ export class GitService implements Disposable { : Strings.normalizePath(paths.relative(repoPath, fileNameOrUri.fsPath)); const blob = await Git.rev_parse__verify(repoPath, ref, fileName); - if (blob == null) return ref; + if (blob == null) return GitRevision.deletedOrMissing; return (await Git.log__find_object(repoPath, blob, ref)) ?? ref; }