mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-25 15:38:33 +02:00
do it for the other method too
This commit is contained in:
parent
b6a34ec17e
commit
4c0e7df9fc
1 changed files with 10 additions and 4 deletions
|
@ -439,13 +439,19 @@ GitEngine.prototype.findCommonAncestorForRemote = function(myTarget) {
|
|||
};
|
||||
|
||||
GitEngine.prototype.findCommonAncestorWithRemote = function(originTarget) {
|
||||
if (this.refs[originTarget]) {
|
||||
return 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
|
||||
while (!this.refs[originTarget]) {
|
||||
var parents = this.origin.refs[originTarget].get('parents');
|
||||
originTarget = parents[0].get('id');
|
||||
if (parents.length === 1) {
|
||||
return this.findCommonAncestorWithRemote(parents[0].get('id'));
|
||||
}
|
||||
return originTarget;
|
||||
// Like above, could have two parents
|
||||
var leftTarget = this.findCommonAncestorWithRemote(parents[0].get('id'));
|
||||
var rightTarget = this.findCommonAncestorWithRemote(parents[1].get('id'));
|
||||
return this.getCommonAncestor(leftTarget, rightTarget, true /* dont throw */).get('id');
|
||||
};
|
||||
|
||||
GitEngine.prototype.makeBranchOnOriginAndTrack = function(branchName, target) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue