Skip to content

Commit

Permalink
Fixes #806 - use merge base with .. compares
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Aug 1, 2019
1 parent 772fe27 commit 0f5c4ab
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

### Fixed

- 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
- Fixes [#756](https://github.com/eamodio/vscode-gitlens/issues/756) - Merge commit shows only the changes from the last commit on those files
- Fixes [#809](https://github.com/eamodio/vscode-gitlens/issues/809) - Wrong commit diff in file history
- Fixes [#685](https://github.com/eamodio/vscode-gitlens/issues/685) - GitLens not loading for a single repository
Expand Down
9 changes: 7 additions & 2 deletions src/views/nodes/compareBranchNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,15 @@ export class CompareBranchNode extends ViewNode<RepositoriesView> {
return `gitlens:repository(${this.branch.repoPath}):compare:branch(${this.branch.name}):compareWith`;
}

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

if (this._children === undefined) {
let ref1 = (this._compareWith && this._compareWith.ref) || 'HEAD';
if (this.comparisonNotation === '..') {
ref1 = (await Container.git.getMergeBase(this.branch.repoPath, ref1, this.branch.ref)) || ref1;
}

this._children = [
new ResultsCommitsNode(
this.view,
Expand All @@ -56,7 +61,7 @@ export class CompareBranchNode extends ViewNode<RepositoriesView> {
this.view,
this,
this.uri.repoPath!,
(this._compareWith && this._compareWith.ref) || 'HEAD',
ref1,
this.compareWithWorkingTree ? '' : this.branch.ref,
this.getFilesQuery.bind(this)
)
Expand Down
9 changes: 7 additions & 2 deletions src/views/nodes/compareResultsNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ export class CompareResultsNode extends SubscribeableViewNode<CompareView> {
return this._ref2;
}

getChildren(): ViewNode[] {
async getChildren(): Promise<ViewNode[]> {
if (this._children === undefined) {
let ref1 = this._ref1.ref;
if (this.comparisonNotation === '..') {
ref1 = (await Container.git.getMergeBase(this.repoPath, ref1, this._ref2.ref)) || ref1;
}

this._children = [
new ResultsCommitsNode(
this.view,
Expand All @@ -67,7 +72,7 @@ export class CompareResultsNode extends SubscribeableViewNode<CompareView> {
this.view,
this,
this.uri.repoPath!,
this._ref1.ref,
ref1,
this._ref2.ref,
this.getFilesQuery.bind(this)
)
Expand Down

0 comments on commit 0f5c4ab

Please sign in to comment.