[Origin] Fixed pull command throwing too early during no fetch case

This commit is contained in:
Peter Cottle 2013-07-04 17:27:03 -07:00
parent 63a88a6885
commit 92e2e303ed
6 changed files with 84 additions and 21 deletions

View file

@ -755,8 +755,10 @@ GitEngine.prototype.getTargetGraphDifference = function(
target,
source,
targetBranch,
sourceBranch
sourceBranch,
options
) {
options = options || {};
sourceBranch = source.resolveID(sourceBranch);
var targetSet = target.getUpstreamSet(targetBranch);
@ -766,9 +768,14 @@ GitEngine.prototype.getTargetGraphDifference = function(
var sourceStartCommitJSON = sourceTree.commits[sourceStartCommit.get('id')];
if (target.refs[sourceStartCommitJSON.id]) {
throw new GitError({
msg: intl.str('git-error-origin-fetch-uptodate')
});
// either we throw since theres no work to be done, or we return an empty array
if (options.dontThrowOnNoFetch) {
return [];
} else {
throw new GitError({
msg: intl.str('git-error-origin-fetch-uptodate')
});
}
}
// ok great, we have our starting point and our stopping set. lets go ahead
@ -931,9 +938,22 @@ GitEngine.prototype.fetch = function(options) {
this,
this.origin,
localBranch,
remoteBranch
remoteBranch,
options
);
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
};
}
var makeCommit = _.bind(function(id, parentIDs) {
// need to get the parents first. since we order by depth, we know
// the dependencies are there already
@ -1006,7 +1026,8 @@ GitEngine.prototype.pull = function() {
// no matter what fetch
var pendingFetch = this.fetch({
dontResolvePromise: true
dontResolvePromise: true,
dontThrowOnNoFetch: true
});
// then either rebase or merge
if (this.commandOptions['--rebase']) {