Skip to content

Commit f7d0bb2

Browse files
committed
don't check for changed files when checking out a new branch
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
1 parent 1a57cab commit f7d0bb2

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/model.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -384,15 +384,17 @@ export class GitExtension implements IGitExtension {
384384
'git:checkout',
385385
async () => {
386386
let changes;
387-
if (body.checkout_branch) {
388-
changes = await this._changedFiles(
389-
this._currentBranch.name,
390-
body.branchname
391-
);
392-
} else if (body.filename) {
393-
changes = { files: [body.filename] };
394-
} else {
395-
changes = await this._changedFiles('WORKING', 'HEAD');
387+
if (!body.new_check) {
388+
if (body.checkout_branch && !body.new_check) {
389+
changes = await this._changedFiles(
390+
this._currentBranch.name,
391+
body.branchname
392+
);
393+
} else if (body.filename) {
394+
changes = { files: [body.filename] };
395+
} else {
396+
changes = await this._changedFiles('WORKING', 'HEAD');
397+
}
396398
}
397399

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

404-
changes.files?.forEach(file => this._revertFile(file));
406+
changes?.files?.forEach(file => this._revertFile(file));
405407
return d;
406408
}
407409
);

0 commit comments

Comments
 (0)