diff --git a/__tests__/remote.spec.js b/__tests__/remote.spec.js index 5bad8e5e..9f5f51e6 100644 --- a/__tests__/remote.spec.js +++ b/__tests__/remote.spec.js @@ -120,7 +120,7 @@ describe('Git Remotes', function() { '{"branches":{"master":{"target":"C2","id":"master","remoteTrackingBranchID":"o/master"},"side":{"target":"C3","id":"side","remoteTrackingBranchID":"o/side"},"o/master":{"target":"C2","id":"o/master","remoteTrackingBranchID":null},"o/side":{"target":"C3","id":"o/side","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"},"C3":{"parents":["C1"],"id":"C3"}},"HEAD":{"target":"side","id":"HEAD"},"originTree":{"branches":{"master":{"target":"C2","id":"master","remoteTrackingBranchID":null},"side":{"target":"C3","id":"side","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"},"C3":{"parents":["C1"],"id":"C3"}},"HEAD":{"target":"master","id":"HEAD"}}}' ); }); - + it('sets tracking when checking out remote branch', function() { expectTreeAsync( 'git clone; git checkout -b side o/master;git fakeTeamwork;git pull', @@ -374,6 +374,13 @@ describe('Git Remotes', function() { ); }); + it('pulls with rebase in other weird situation with just fast forward', function() { + expectTreeAsync( + 'git clone; git fakeTeamwork; git pull --rebase', + '{"branches":{"master":{"target":"C2","id":"master","remoteTrackingBranchID":"o/master"},"o/master":{"target":"C2","id":"o/master","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"tags":{},"HEAD":{"target":"master","id":"HEAD"},"originTree":{"branches":{"master":{"target":"C2","id":"master","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"tags":{},"HEAD":{"target":"master","id":"HEAD"}}}' + ); + }); + /* TODO -- enable this back when we have better async tree compare, it takes too long right now it('will correctly resolve the dependency order of commits when fetching or pushing', function() { expectTreeAsync( @@ -405,4 +412,3 @@ describe('Git Remotes', function() { }); - diff --git a/src/js/git/index.js b/src/js/git/index.js index 3e41c84c..ce996c57 100644 --- a/src/js/git/index.js +++ b/src/js/git/index.js @@ -1423,13 +1423,20 @@ GitEngine.prototype.pullFinishWithRebase = function( chain = chain.then(function() { pendingFetch.dontResolvePromise = true; + // Lets move the git pull --rebase check up here. + if (this.isUpstreamOf(localBranch, remoteBranch)) { + this.setTargetLocation( + localBranch, + this.getCommitFromRef(remoteBranch) + ); + this.checkout(localBranch); + return this.animationFactory.playRefreshAnimation(this.gitVisuals); + } + try { return this.rebase(remoteBranch, localBranch, pendingFetch); } catch (err) { this.filterError(err); - // we make one exception here to match the behavior of - // git pull --rebase. If the rebase is empty we just - // simply checkout the new location if (err.getMsg() !== intl.str('git-error-rebase-none')) { throw err; } @@ -2087,6 +2094,7 @@ GitEngine.prototype.hgRebase = function(destination, base) { GitEngine.prototype.rebase = function(targetSource, currentLocation, options) { // first some conditions + debugger; if (this.isUpstreamOf(targetSource, currentLocation)) { this.command.setResult(intl.str('git-result-uptodate')); @@ -3057,4 +3065,3 @@ exports.Commit = Commit; exports.Branch = Branch; exports.Tag = Tag; exports.Ref = Ref; -