From 2c2741ca206baac3fd96b4da61ecbfda99ebedcc Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 4 Sep 2019 13:55:36 -0400 Subject: [PATCH] Fixes #842 - broken compare to working tree --- CHANGELOG.md | 7 ++++--- src/views/nodes/compareResultsNode.ts | 16 +++++++++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a58e01d..9ad46bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,11 +50,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Fixed -- Fixes [#794](https://github.com/eamodio/vscode-gitlens/issues/794) - Can't get back to settings page easily -- Fixes [#821](https://github.com/eamodio/vscode-gitlens/issues/821) - Wrong comparison order in the Compare view when using Compare [HEAD|Working Tree] With comands +- Fixes [#842](https://github.com/eamodio/vscode-gitlens/issues/842) - List of changed files in comparison to working tree only shows changed files in comparison to HEAD - Fixes [#828](https://github.com/eamodio/vscode-gitlens/issues/828) - Version comparison to show welcome message is not future proof — thanks to [PR #829](https://github.com/eamodio/vscode-gitlens/pull/829) by Arunprasad Rajkumar ([@arajkumar](https://github.com/arajkumar)) -- Fixes typo of "workbench.colorCustomization" in README — thanks to [PR #823](https://github.com/eamodio/vscode-gitlens/pull/823) by Kwok ([@mankwok](https://github.com/mankwok)) +- Fixes [#821](https://github.com/eamodio/vscode-gitlens/issues/821) - Wrong comparison order in the Compare view when using Compare [HEAD|Working Tree] With comands +- Fixes [#794](https://github.com/eamodio/vscode-gitlens/issues/794) - Can't get back to settings page easily - Fixes [#738](https://github.com/eamodio/vscode-gitlens/issues/738) - Disable showWhatsNewAfterUpgrades notification +- Fixes typo of "workbench.colorCustomization" in README — thanks to [PR #823](https://github.com/eamodio/vscode-gitlens/pull/823) by Kwok ([@mankwok](https://github.com/mankwok)) - Fixes an issue with branch sorting when the current branch was tree'd - Fixes an issue with the _Explore Repository from Here_ command in the latest VS Code Insiders diff --git a/src/views/nodes/compareResultsNode.ts b/src/views/nodes/compareResultsNode.ts index 14d78b8..4fd1a1d 100644 --- a/src/views/nodes/compareResultsNode.ts +++ b/src/views/nodes/compareResultsNode.ts @@ -198,7 +198,7 @@ export class CompareResultsNode extends SubscribeableViewNode { private async getCommitsQuery(maxCount: number | undefined): Promise { const log = await Container.git.getLog(this.uri.repoPath!, { maxCount: maxCount, - ref: `${this._compareWith.ref || 'HEAD'}${this.comparisonNotation}${this._ref.ref}` + ref: `${this._compareWith.ref || 'HEAD'}${this.comparisonNotation}${this._ref.ref || 'HEAD'}` }); const count = log !== undefined ? log.count : 0; @@ -211,10 +211,16 @@ export class CompareResultsNode extends SubscribeableViewNode { } private async getFilesQuery(): Promise { - const diff = await Container.git.getDiffStatus( - this.uri.repoPath!, - `${this._compareWith.ref || 'HEAD'}${this.diffComparisonNotation}${this._ref.ref || 'HEAD'}` - ); + let comparison; + if (this._compareWith.ref === '') { + comparison = this._ref.ref; + } else if (this._ref.ref === '') { + comparison = this._compareWith.ref; + } else { + comparison = `${this._compareWith.ref}${this.diffComparisonNotation}${this._ref.ref}`; + } + + const diff = await Container.git.getDiffStatus(this.uri.repoPath!, comparison); return { label: `${Strings.pluralize('file', diff !== undefined ? diff.length : 0, { zero: 'No' })} changed`,