Subject: Re: [PATCH] cherry-pick: when pick fails, explain how to cancel

From: Piotr Krukowiecki <[email-masked]>
Date: Fri, 18 Feb 2011 22:38:03 +0100

W dniu 18.02.2011 02:24, Jonathan Nieder pisze:
> Piotr Krukowiecki wrote:
>> 1. add hint to cherry-pick how to abort merge, for example:
>>    hint: use 'git reset --merge ORIG_HEAD' to abort merge
> 
> Good idea.  "git cherry-pick" does not set ORIG_HEAD, so I
> put "git reset --merge HEAD" instead.

You're right. I was sure I have tested it, but when I try to 
use ORIG_HEAD now it does not work.

I took it from Documentation/git-cherry-pick.txt, which seem
to be wrong:

   $ git cherry-pick topic^             <1>
   $ git diff                           <2>
   $ git reset --merge ORIG_HEAD        <3>
   [...]
   <3> cancel the cherry-pick.  In other words, return to the
   pre-cherry-pick state, preserving any local modifications you had in
   the working tree.

>> 2. add hint to status how to abort merge, for example:
>>    #   (use 'git reset --merge ORIG_HEAD' to abort merge)
> 
> "git reset --merge" will remove local changes marked with "git add",
> under the assumption that they were part of the conflict resolution
> and thus should be cleared away.

Didn't know that (one probably shouldn't merge with uncommitted/local
changes anyway). git-reset.txt mentions it, but there's no explicit
warning.

> This leaves me afraid of the following scenario:
> 
> 	git pull
> 	# conflict?  agh!
> 
> 	# ... two days later ...
> 	... hack hack hack ...
> 	... add add add ...
> 	git commit;	# fails because of unmerged files
> 
> 	# whoops, forgot about that merge.
> 	# Let's do what it says to do:
> 	git reset --merge ORIG_HEAD
> 
> It seems safest to only recommend "reset --merge" immediately
> after a mergy operation.

Is it possible to recognize that you have something more than what
was cause by the merge/cherry-pick?

>> The ORIG_HEAD is specified in man page example.
> 
> I assume you mean on the git-reset page?  It might be nice to add
> more examples and to update the current ones with current best
> practice (e.g., using reset --keep more often).

Yes, it says:

   Running "git reset --hard ORIG_HEAD" will let you go back to where
   you were, but it will discard your local changes, which you do not
   want.  "git reset --merge" keeps your local changes.

>> git-cherry-pick uses word "cancel" in man page (in example) and
>> git-merge uses word "abort" for (as I understand) the same action.
> 
> Hmm, where is this example in the cherry-pick manpage?

It's in the Documentation/cherry-pick.txt (in current master). I assume 
man pages are generated from those text files. I have also cited it at 
the beginning of this mail.

-- 
Piotr Krukowiecki