Browse Source

Fixes #1157 - branch compare with working tree off

main
Eric Amodio 4 years ago
parent
commit
13a03da5b2
2 changed files with 23 additions and 7 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +22
    -7
      src/views/nodes/compareBranchNode.ts

+ 1
- 0
CHANGELOG.md View File

@ -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

+ 22
- 7
src/views/nodes/compareBranchNode.ts View File

@ -223,15 +223,30 @@ export class CompareBranchNode extends ViewNode
}
private async getAheadFilesQuery(): Promise<FilesQueryResults> {
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,

Loading…
Cancel
Save