diff --git a/spec/create.js b/spec/create.js index 4e9fa7d0..147f393d 100644 --- a/spec/create.js +++ b/spec/create.js @@ -1,6 +1,7 @@ var TreeCompare = require('../src/js/git/treeCompare').TreeCompare; var HeadlessGit = require('../src/js/git/headless').HeadlessGit; +var fs = require('fs'); prompt = require('prompt'); prompt.start(); diff --git a/spec/remote.spec.js b/spec/remote.spec.js index c9270a3a..03f5ffc4 100644 --- a/spec/remote.spec.js +++ b/spec/remote.spec.js @@ -283,5 +283,19 @@ describe('Git Remotes', function() { ); }); + it('correctly resolves source during git fetch with params', function() { + expectTreeAsync( + 'git clone; git push master:foo; git fakeTeamwork foo 2; git fetch origin foo^:blah', + '{"branches":{"master":{"target":"C1","id":"master","remoteTrackingBranchID":"o/master"},"o/master":{"target":"C1","id":"o/master","remoteTrackingBranchID":null},"o/foo":{"target":"C1","id":"o/foo","remoteTrackingBranchID":null},"blah":{"target":"C2","id":"blah","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"master","id":"HEAD"},"originTree":{"branches":{"master":{"target":"C1","id":"master","remoteTrackingBranchID":null},"foo":{"target":"C3","id":"foo","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"},"C3":{"parents":["C2"],"id":"C3"}},"HEAD":{"target":"foo","id":"HEAD"}}}' + ); + }); + + it('correctly makes a new branch during fetch despite nothing to download', function() { + expectTreeAsync( + 'git clone; git push master:foo', + '{"branches":{"master":{"target":"C1","id":"master","remoteTrackingBranchID":"o/master"},"o/master":{"target":"C1","id":"o/master","remoteTrackingBranchID":null},"o/foo":{"target":"C1","id":"o/foo","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"HEAD":{"target":"master","id":"HEAD"},"originTree":{"branches":{"master":{"target":"C1","id":"master","remoteTrackingBranchID":null},"foo":{"target":"C1","id":"foo","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"HEAD":{"target":"master","id":"HEAD"}}}' + ); + }); + }); diff --git a/src/js/git/index.js b/src/js/git/index.js index dbab5892..9832421d 100644 --- a/src/js/git/index.js +++ b/src/js/git/index.js @@ -1135,17 +1135,13 @@ GitEngine.prototype.fetchCore = function(sourceDestPairs, options) { commitsToMake = this.getUniqueObjects(commitsToMake); commitsToMake = this.descendSortDepth(commitsToMake); - if (commitsToMake.length === 0) { - this.command.addWarning(intl.str( - 'git-error-origin-fetch-uptodate' - )); - // no fetch needed... - var d = Q.defer(); - return { - deferred: d, - chain: d.promise - }; - } + // now here is the tricky part -- the difference between local master + // and remote master might be commits C2, C3, and C4, but we + // might already have those commits. In this case, we dont need to + // make them, so filter these out + commitsToMake = _.filter(commitsToMake, function(commitJSON) { + return !this.refs[commitJSON.id]; + }, this); var makeCommit = _.bind(function(id, parentIDs) { // need to get the parents first. since we order by depth, we know