diff --git a/CHANGELOG.md b/CHANGELOG.md index c55bd0d..fc134f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Fixed - Fixes [#1150](https://github.com/eamodio/vscode-gitlens/issues/1150) - Cannot read property 'provider' of undefined +- Fixes [#1157](https://github.com/eamodio/vscode-gitlens/issues/1157) - GitLens report `X files changed` when comparing working tree with a branch having identical files ## [11.0.0] - 2020-11-14 diff --git a/src/views/nodes/compareBranchNode.ts b/src/views/nodes/compareBranchNode.ts index fd52d2f..9accc2b 100644 --- a/src/views/nodes/compareBranchNode.ts +++ b/src/views/nodes/compareBranchNode.ts @@ -223,15 +223,30 @@ export class CompareBranchNode extends ViewNode { - const files = await Container.git.getDiffStatus( - this.uri.repoPath!, - this.compareWithWorkingTree - ? // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - this._compareWith?.ref || 'HEAD' - : // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - GitRevision.createRange(this._compareWith?.ref || 'HEAD', this.branch.ref, '...'), + let files = await Container.git.getDiffStatus( + this.repoPath, + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + GitRevision.createRange(this._compareWith?.ref || 'HEAD', this.branch.ref || 'HEAD', '...'), ); + if (this.compareWithWorkingTree) { + const workingFiles = await Container.git.getDiffStatus(this.repoPath, 'HEAD'); + if (workingFiles != null) { + if (files != null) { + for (const wf of workingFiles) { + const index = files.findIndex(f => f.fileName === wf.fileName); + if (index !== -1) { + files.splice(index, 1, wf); + } else { + files.push(wf); + } + } + } else { + files = workingFiles; + } + } + } + return { label: `${Strings.pluralize('file', files?.length ?? 0, { zero: 'No' })} changed`, files: files,