mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-25 15:38:33 +02:00
Resolves #459 -- parent ordering can break some operations
This commit is contained in:
parent
69b99b82d0
commit
b6a34ec17e
3 changed files with 19 additions and 10 deletions
|
@ -418,12 +418,24 @@ 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');
|
||||
}
|
||||
if (this.origin.refs[myTarget]) {
|
||||
return myTarget;
|
||||
}
|
||||
var parents = this.refs[myTarget].get('parents');
|
||||
if (parents.length === 1) {
|
||||
// Easy, we only have one parent. lets just go upwards
|
||||
myTarget = parents[0].get('id');
|
||||
// Recurse upwards to find where our remote has a commit.
|
||||
return this.findCommonAncestorForRemote(myTarget);
|
||||
}
|
||||
// We have multiple parents so find out where these two meet.
|
||||
var leftTarget = this.findCommonAncestorForRemote(parents[0].get('id'));
|
||||
var rightTarget = this.findCommonAncestorForRemote(parents[1].get('id'));
|
||||
return this.getCommonAncestor(
|
||||
leftTarget,
|
||||
rightTarget,
|
||||
true // dont throw since we dont know the order here.
|
||||
).get('id');
|
||||
};
|
||||
|
||||
GitEngine.prototype.findCommonAncestorWithRemote = function(originTarget) {
|
||||
|
@ -2100,7 +2112,6 @@ 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'));
|
||||
|
||||
|
@ -2764,8 +2775,8 @@ GitEngine.prototype.log = function(ref, omitSet) {
|
|||
});
|
||||
};
|
||||
|
||||
GitEngine.prototype.getCommonAncestor = function(ancestor, cousin) {
|
||||
if (this.isUpstreamOf(cousin, ancestor)) {
|
||||
GitEngine.prototype.getCommonAncestor = function(ancestor, cousin, dontThrow) {
|
||||
if (this.isUpstreamOf(cousin, ancestor) && !dontThrow) {
|
||||
throw new Error('Dont use common ancestor if we are upstream!');
|
||||
}
|
||||
|
||||
|
|
|
@ -476,4 +476,3 @@ var Sandbox = Backbone.View.extend({
|
|||
});
|
||||
|
||||
exports.Sandbox = Sandbox;
|
||||
|
||||
|
|
|
@ -290,4 +290,3 @@ var Visualization = Backbone.View.extend({
|
|||
});
|
||||
|
||||
exports.Visualization = Visualization;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue