From f7d0bb2bd1b780e2757de4efe3db887c833ce311 Mon Sep 17 00:00:00 2001 From: Ian Hunt-Isaak Date: Thu, 19 Nov 2020 16:33:41 -0500 Subject: [PATCH] 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 --- src/model.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/model.ts b/src/model.ts index 3a1879224..5f375ee1f 100644 --- a/src/model.ts +++ b/src/model.ts @@ -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( @@ -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; } );