Skip to content

Commit 0f5c4ab

Browse files
committed
Fixes #806 - use merge base with .. compares
1 parent 772fe27 commit 0f5c4ab

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
88

99
### Fixed
1010

11+
- Fixes [#806](https://github.com/eamodio/vscode-gitlens/issues/806) - file diff in two-dot branch compare should only show the changes in one branch
1112
- Fixes [#756](https://github.com/eamodio/vscode-gitlens/issues/756) - Merge commit shows only the changes from the last commit on those files
1213
- Fixes [#809](https://github.com/eamodio/vscode-gitlens/issues/809) - Wrong commit diff in file history
1314
- Fixes [#685](https://github.com/eamodio/vscode-gitlens/issues/685) - GitLens not loading for a single repository

src/views/nodes/compareBranchNode.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,15 @@ export class CompareBranchNode extends ViewNode<RepositoriesView> {
3636
return `gitlens:repository(${this.branch.repoPath}):compare:branch(${this.branch.name}):compareWith`;
3737
}
3838

39-
getChildren(): ViewNode[] {
39+
async getChildren(): Promise<ViewNode[]> {
4040
if (this._compareWith === undefined) return [];
4141

4242
if (this._children === undefined) {
43+
let ref1 = (this._compareWith && this._compareWith.ref) || 'HEAD';
44+
if (this.comparisonNotation === '..') {
45+
ref1 = (await Container.git.getMergeBase(this.branch.repoPath, ref1, this.branch.ref)) || ref1;
46+
}
47+
4348
this._children = [
4449
new ResultsCommitsNode(
4550
this.view,
@@ -56,7 +61,7 @@ export class CompareBranchNode extends ViewNode<RepositoriesView> {
5661
this.view,
5762
this,
5863
this.uri.repoPath!,
59-
(this._compareWith && this._compareWith.ref) || 'HEAD',
64+
ref1,
6065
this.compareWithWorkingTree ? '' : this.branch.ref,
6166
this.getFilesQuery.bind(this)
6267
)

src/views/nodes/compareResultsNode.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ export class CompareResultsNode extends SubscribeableViewNode<CompareView> {
4949
return this._ref2;
5050
}
5151

52-
getChildren(): ViewNode[] {
52+
async getChildren(): Promise<ViewNode[]> {
5353
if (this._children === undefined) {
54+
let ref1 = this._ref1.ref;
55+
if (this.comparisonNotation === '..') {
56+
ref1 = (await Container.git.getMergeBase(this.repoPath, ref1, this._ref2.ref)) || ref1;
57+
}
58+
5459
this._children = [
5560
new ResultsCommitsNode(
5661
this.view,
@@ -67,7 +72,7 @@ export class CompareResultsNode extends SubscribeableViewNode<CompareView> {
6772
this.view,
6873
this,
6974
this.uri.repoPath!,
70-
this._ref1.ref,
75+
ref1,
7176
this._ref2.ref,
7277
this.getFilesQuery.bind(this)
7378
)

0 commit comments

Comments
 (0)