Subject: Re: [PATCH] rebase -i: remove CHERRY_PICK_HEAD when cherry-pick failed

From: Andrew Wong <[email-masked]>
Date: Tue, 03 Apr 2012 17:01:00 -0400

On 04/03/2012 10:45 AM, Jonathan Nieder wrote:
> Ok.  Now the user (sensibly) ignores the message from cherry-pick and
> just runs "git rebase --continue".  The rebase finishes but nobody
> feels it's his responsibility to remove the .git/CHERRY_PICK_HEAD file
> and it gets left behind.
>   
Yes, that's exactly what's happening. That particular rebase will leave
behind CHERRY_PICK_HEAD, which have bad consequences such as:
1. Confuses __git_ps1 (from git-completion.bash) into thinking a
cherry-pick is still in progress. (which is what started this discussion)
2. Cause "cherry-pick --continue" to think a cherry-pick is still in
progress.
3. Similarly, if a user then continue on to modifying their files, and
do a "add" and "commit", "commit" would reuse the message from the
CHERRY_PICK_HEAD.

> I suspect a more appropriate long-term fix would involve "git
> cherry-pick" noticing when a patch has resolved to nothing instead of
> leaving it to "git commit" to detect that.
>   
I actually tried implementing a fix like that too. But then I thought
there might be other scenarios where "commit" could fail, and it doesn't
seem to make sense for "cherry-pick" to have to detect all possible
"commit" failures. Though it also feels like the question of whether or
not "cherry-pick" should detects the "empty commit" is a separate issue
altogether.

Besides the "empty commit" failure, "cherry-pick" can still run into
various errors, such as merge conflict. So it will have to keep a state
somehow. And instead of having "cherry-pick" make special cases for
"rebase -i" to remove the state, it makes more sense to teach "rebase
-i" that "cherry-pick" now keeps a state on failure. So if "cherry-pick"
fails, "rebase -i" is responsible for clearing that state. And that's
what this patch is supposed to do.

Perhaps I should rephrase my description to reflect this better?
Something along the line of: "cherry-pick" now keeps a state on failure.
Instead of having a special case inside the sequencer to remove the
state, we teach "rebase -i" that we need to clear the state.