rebase detached head thing

This commit is contained in:
Peter Cottle 2012-10-21 13:16:36 -07:00
parent 85de7c5a04
commit 85b66e83bd

View file

@ -708,12 +708,6 @@ GitEngine.prototype.idSortFunc = function(cA, cB) {
}; };
GitEngine.prototype.rebaseStarter = function() { GitEngine.prototype.rebaseStarter = function() {
if (this.getDetachedHead()) {
throw new GitError({
msg: "No rebasing in detached head!"
});
}
if (this.generalArgs.length > 2) { if (this.generalArgs.length > 2) {
throw new GitError({ throw new GitError({
msg: 'rebase with more than 2 arguments doesnt make sense!' msg: 'rebase with more than 2 arguments doesnt make sense!'
@ -724,9 +718,17 @@ GitEngine.prototype.rebaseStarter = function() {
msg: 'Give me a branch to rebase onto!' msg: 'Give me a branch to rebase onto!'
}); });
} }
if (this.generalArgs.length == 1) { if (this.generalArgs.length == 1) {
this.generalArgs.push('HEAD'); this.generalArgs.push('HEAD');
if (this.getDetachedHead()) {
throw new GitError({
msg: "No rebasing in detached head when you are " +
"referring to HEAD by only passing in one argument!"
});
} }
}
var response = this.rebase(this.generalArgs[0], this.generalArgs[1]); var response = this.rebase(this.generalArgs[0], this.generalArgs[1]);
if (response === undefined) { if (response === undefined) {
@ -856,6 +858,11 @@ GitEngine.prototype.rebase = function(targetSource, currentLocation) {
// now we just need to update where we are // now we just need to update where we are
this.setLocationTarget(currentLocation, base); this.setLocationTarget(currentLocation, base);
// if we are in detached head, update that too
if (this.getDetachedHead()) {
this.setLocationTarget(this.HEAD, base);
}
// for animation // for animation
return animationResponse; return animationResponse;
}; };