Skip to content

Commit

Permalink
don't check for changed files when checking out a new branch
Browse files Browse the repository at this point in the history
This should never cause files to change, and was failing because we were asking for the git diff between the current branch and one that did not yet exist
  • Loading branch information
ianhi committed Nov 19, 2020
1 parent 1a57cab commit f7d0bb2
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,17 @@ export class GitExtension implements IGitExtension {
'git:checkout',
async () => {
let changes;
if (body.checkout_branch) {
changes = await this._changedFiles(
this._currentBranch.name,
body.branchname
);
} else if (body.filename) {
changes = { files: [body.filename] };
} else {
changes = await this._changedFiles('WORKING', 'HEAD');
if (!body.new_check) {
if (body.checkout_branch && !body.new_check) {
changes = await this._changedFiles(
this._currentBranch.name,
body.branchname
);
} else if (body.filename) {
changes = { files: [body.filename] };
} else {
changes = await this._changedFiles('WORKING', 'HEAD');
}
}

const d = await requestAPI<Git.ICheckoutResult>(
Expand All @@ -401,7 +403,7 @@ export class GitExtension implements IGitExtension {
body
);

changes.files?.forEach(file => this._revertFile(file));
changes?.files?.forEach(file => this._revertFile(file));
return d;
}
);
Expand Down

0 comments on commit f7d0bb2

Please sign in to comment.