When git rebase is aborted, it will return the HEAD to the rebased branch (which has not moved). If the current branch is "topic" and a run of "git rebase master" is aborted, "topic" is therefore checked out, which is both what I expect and what I want. When the two-argument version of git rebase is used, as in "git rebase master topic", and then aborted, "topic" will be checked out. This is not what I would expect, although I'm aware of it by now, and usually not what I want. I would expect to be returned to the branch/commit that was checked out when I started "git rebase master topic".
In most cases, this is just a small annoyance, since it's usually quick and easy to manually switch back to the original branch. However, I have run into at least two cases where it has been a bit more annoying:
1. When on a detached HEAD and running "git rebase HEAD topic", if
you abort the rebase, you will have to look up the old commit in
the reflog. 2. I once was rebasing many old branches, mostly to see which ones
could be rebased without conflicts. The project I was working on
was pretty big and a lot had changed since those old branches were
created. If a "new" branch is currently checked out and "git
rebase master old-branch" is run and causes conflicts, the old
branch would be checked out. In my case, this would take 5-10
seconds. Since Junio improved rebase in 0cb0664 (rebase [--onto O]
A B: omit needless checkout, 2008-03-15), there will be no
checkouts of any "old" commit in the successful case, so it's a
shame that it has to happen in the unsuccessful case when the
rebase is aborted.Are there valid cases where the current behavior is bettter?
I suppose we can not just change the current behavior due to backward compatibility constraints. We could introduce a configuration variable, of we could perhaps change it in 1.8.0. Maybe the problem is not big enough to do either...
/Martin