mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 00:40:07 +02:00
rebase onto implemented
This commit is contained in:
parent
592399b1db
commit
521cc0e809
3 changed files with 41 additions and 8 deletions
|
@ -615,7 +615,8 @@ var commandConfig = {
|
|||
'--interactive-test',
|
||||
'--aboveAll',
|
||||
'-p',
|
||||
'--preserve-merges'
|
||||
'--preserve-merges',
|
||||
'--onto'
|
||||
],
|
||||
regex: /^git +rebase($|\s)/,
|
||||
execute: function(engine, command) {
|
||||
|
@ -645,6 +646,17 @@ var commandConfig = {
|
|||
return;
|
||||
}
|
||||
|
||||
if (commandOptions['--onto']) {
|
||||
var args = commandOptions['--onto'].concat(generalArgs);
|
||||
command.threeArgsImpliedHead(args, ' --onto');
|
||||
|
||||
engine.rebaseOnto(args[0], args[1], args[2], {
|
||||
preserveMerges: commandOptions['-p'] || commandOptions['--preserve-merges']
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
command.twoArgsImpliedHead(generalArgs);
|
||||
engine.rebase(generalArgs[0], generalArgs[1], {
|
||||
preserveMerges: commandOptions['-p'] || commandOptions['--preserve-merges']
|
||||
|
|
|
@ -2165,6 +2165,21 @@ GitEngine.prototype.rebase = function(targetSource, currentLocation, options) {
|
|||
return this.rebaseFinish(toRebaseRough, stopSet, targetSource, currentLocation, options);
|
||||
};
|
||||
|
||||
GitEngine.prototype.rebaseOnto = function(targetSource, oldSource, unit, options) {
|
||||
if (this.isUpstreamOf(unit, targetSource)) {
|
||||
this.setTargetLocation(unit, this.getCommitFromRef(targetSource));
|
||||
this.command.setResult(intl.str('git-result-fastforward'));
|
||||
|
||||
this.checkout(unit);
|
||||
return;
|
||||
}
|
||||
|
||||
var stopSet = Graph.getUpstreamSet(this, targetSource);
|
||||
var oldBranchSet = Graph.getUpstreamSet(this, oldSource);
|
||||
var toRebaseRough = this.getUpstreamDiffFromSet(oldBranchSet, unit);
|
||||
return this.rebaseFinish(toRebaseRough, stopSet, targetSource, unit, options);
|
||||
};
|
||||
|
||||
GitEngine.prototype.getUpstreamDiffSetFromSet = function(stopSet, location) {
|
||||
var set = {};
|
||||
this.getUpstreamDiffFromSet(stopSet, location).forEach(function (commit) {
|
||||
|
|
|
@ -124,17 +124,23 @@ var Command = Backbone.Model.extend({
|
|||
}
|
||||
},
|
||||
|
||||
oneArgImpliedHead: function(args, option) {
|
||||
this.validateArgBounds(args, 0, 1, option);
|
||||
argImpliedHead: function (args, lower, upper, option) {
|
||||
// our args we expect to be between {lower} and {upper}
|
||||
this.validateArgBounds(args, lower, upper, option);
|
||||
// and if it's one, add a HEAD to the back
|
||||
this.impliedHead(args, 0);
|
||||
this.impliedHead(args, lower);
|
||||
},
|
||||
|
||||
oneArgImpliedHead: function(args, option) {
|
||||
this.argImpliedHead(args, 0, 1, option);
|
||||
},
|
||||
|
||||
twoArgsImpliedHead: function(args, option) {
|
||||
// our args we expect to be between 1 and 2
|
||||
this.validateArgBounds(args, 1, 2, option);
|
||||
// and if it's one, add a HEAD to the back
|
||||
this.impliedHead(args, 1);
|
||||
this.argImpliedHead(args, 1, 2, option);
|
||||
},
|
||||
|
||||
threeArgsImpliedHead: function(args, option) {
|
||||
this.argImpliedHead(args, 2, 3, option);
|
||||
},
|
||||
|
||||
oneArgImpliedOrigin: function(args) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue