Browse Source

Fixes issues showing uncommitted and staged content

main
Eric Amodio 6 years ago
parent
commit
70ebec7b81
2 changed files with 13 additions and 3 deletions
  1. +2
    -2
      src/commands/diffWith.ts
  2. +11
    -1
      src/git/gitService.ts

+ 2
- 2
src/commands/diffWith.ts View File

@ -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' }) || '';

+ 11
- 1
src/git/gitService.ts View File

@ -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!);
}

Loading…
Cancel
Save