push args done

This commit is contained in:
Peter Cottle 2013-10-26 14:14:08 -07:00
parent 55d563a9bc
commit dc8df68dac
4 changed files with 109 additions and 5 deletions

View file

@ -394,8 +394,11 @@ GitEngine.prototype.makeBranchIfNeeded = function(branchName) {
if (this.refs[branchName]) {
return;
}
var where = this.findCommonAncestorForRemote(
this.getCommitFromRef('HEAD').get('id')
);
return this.validateAndMakeBranch(branchName, this.getCommitFromRef('HEAD'));
return this.validateAndMakeBranch(branchName, this.getCommitFromRef(where));
};
GitEngine.prototype.makeRemoteBranchForRemote = function(branchName) {
@ -409,6 +412,15 @@ GitEngine.prototype.makeRemoteBranchForRemote = function(branchName) {
);
};
GitEngine.prototype.findCommonAncestorForRemote = function(myTarget) {
// like the method below but opposite
while (!this.origin.refs[myTarget]) {
var parents = this.refs[myTarget].get('parents');
myTarget = parents[0].get('id');
}
return myTarget;
};
GitEngine.prototype.findCommonAncestorWithRemote = function(originTarget) {
// now this is tricky -- our remote could have commits that we do
// not have. so lets go upwards until we find one that we have
@ -429,10 +441,12 @@ GitEngine.prototype.makeBranchOnOriginAndTrack = function(branchName, target) {
this.setLocalToTrackRemote(this.refs[branchName], remoteBranch);
}
var originTarget = this.origin.refs['master'].get('target');
var originTarget = this.findCommonAncestorForRemote(
this.getCommitFromRef(target).get('id')
);
this.origin.makeBranch(
branchName,
originTarget
this.origin.getCommitFromRef(originTarget)
);
};
@ -934,7 +948,7 @@ GitEngine.prototype.push = function(options) {
if (!this.origin.refs[options.destination]) {
this.makeBranchOnOriginAndTrack(
options.destination,
'HEAD'
this.getCommitFromRef(sourceBranch)
);
// play an animation now since we might not have to fast forward
// anything... this is weird because we are punting an animation
@ -1229,6 +1243,11 @@ GitEngine.prototype.pull = function(options) {
destination: options.destination
});
if (!pendingFetch) {
// short circuited for some reason
return;
}
var destBranch = this.refs[options.destination];
// then either rebase or merge
if (options.isRebase) {