Skip to content

Commit 365af9c

Browse files
committed
Changes behavior of diffWithPrevious to always does what it says
Compares the current file with the previous commit to that file
1 parent 55b1a66 commit 365af9c

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/commands/diffWithPrevious.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,15 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
3232
const gitUri = await GitUri.fromUri(uri, this.git);
3333

3434
try {
35-
// If the sha is missing or the file is uncommitted, treat it as a DiffWithWorking
36-
if (gitUri.sha === undefined && await this.git.isFileUncommitted(gitUri)) {
37-
return commands.executeCommand(Commands.DiffWithWorking, uri, { showOptions: args.showOptions } as DiffWithWorkingCommandArgs);
38-
}
39-
4035
const sha = args.commit === undefined ? gitUri.sha : args.commit.sha;
4136

4237
const log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, undefined, sha ? undefined : 2, args.range!);
4338
if (log === undefined) return window.showWarningMessage(`Unable to open compare. File is probably not under source control`);
4439

4540
args.commit = (sha && log.commits.get(sha)) || Iterables.first(log.commits.values());
41+
42+
// If the sha is missing, treat it as a DiffWithWorking
43+
if (gitUri.sha === undefined) return commands.executeCommand(Commands.DiffWithWorking, uri, { commit: args.commit, showOptions: args.showOptions } as DiffWithWorkingCommandArgs);
4644
}
4745
catch (ex) {
4846
Logger.error(ex, 'DiffWithPreviousCommand', `getLogForFile(${gitUri.repoPath}, ${gitUri.fsPath})`);

0 commit comments

Comments
 (0)