Bläddra i källkod

Fixes issue with diff files added in index/working tree

main
Eric Amodio 6 år sedan
förälder
incheckning
f0c5df885f
3 ändrade filer med 11 tillägg och 5 borttagningar
  1. +2
    -1
      src/commands/diffWith.ts
  2. +2
    -0
      src/git/git.ts
  3. +7
    -4
      src/git/gitService.ts

+ 2
- 1
src/commands/diffWith.ts Visa fil

@ -108,7 +108,8 @@ export class DiffWithCommand extends ActiveEditorCommand {
if (args.lhs.sha !== GitService.deletedOrMissingSha) {
lhsSha = args.lhs.sha;
}
if (args.rhs.sha !== GitService.deletedOrMissingSha) {
if (args.rhs.sha && args.rhs.sha !== GitService.deletedOrMissingSha) {
// Ensure that the file still exists in this commit
const status = await Container.git.getFileStatusForCommit(
args.repoPath,

+ 2
- 0
src/git/git.ts Visa fil

@ -511,6 +511,8 @@ export class Git {
}
static async cat_file_validate(repoPath: string, fileName: string, ref: string) {
if (Git.isUncommitted(ref)) return ref;
try {
await git<string>(
{ cwd: repoPath, exceptionHandler: throwExceptionHandler },

+ 7
- 4
src/git/gitService.ts Visa fil

@ -1850,14 +1850,17 @@ export class GitService implements Disposable {
}
async resolveReference(repoPath: string, ref: string, uri?: Uri) {
if (Git.isSha(ref) || !Git.isShaLike(ref) || ref.endsWith('^3')) return ref;
Logger.log(`resolveReference('${repoPath}', '${ref}', '${uri && uri.toString(true)}')`);
if (uri == null) return (await Git.revparse(repoPath, ref)) || ref;
const resolved = Git.isSha(ref) || !Git.isShaLike(ref) || ref.endsWith('^3');
if (uri == null) return resolved ? ref : (await Git.revparse(repoPath, ref)) || ref;
const fileName = Strings.normalizePath(paths.relative(repoPath, uri.fsPath));
const resolvedRef = await Git.log_resolve(repoPath, fileName, ref);
let resolvedRef;
if (!resolved) {
resolvedRef = await Git.log_resolve(repoPath, fileName, ref);
}
const ensuredRef = await Git.cat_file_validate(repoPath, fileName, resolvedRef || ref);
if (ensuredRef === undefined) return ref;

Laddar…
Avbryt
Spara