git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Philippe Blain <levraiphilippeblain@gmail.com>
To: Junio C Hamano <gitster@pobox.com>,
	Philippe Blain via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Erik Cervin Edin <erik@cervined.in>,
	Phillip Wood <phillip.wood@dunelm.org.uk>
Subject: Re: [PATCH 1/5] git-cherry-pick.txt: do not use 'ORIG_HEAD' in example
Date: Mon, 9 Jan 2023 08:56:58 -0500	[thread overview]
Message-ID: <4525699c-eed5-4da6-b469-b73b87525b23@gmail.com> (raw)
In-Reply-To: <xmqqh6x1232e.fsf@gitster.g>


Hi Junio,

Le 2023-01-07 à 21:05, Junio C Hamano a écrit :
> "Philippe Blain via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 
>> The command used in the example to abort the cherry-pick is 'git reset
>> --merge ORIG_HEAD', but cherry-pick does not write 'ORIG_HEAD' before
>> starting its operation.
> 
> Sorry, but I am confused.  Doesn't <1> update ORIG_HEAD used by <3>?
> 
>>  $ git cherry-pick topic^             <1>
>>  $ git diff                           <2>
>> -$ git reset --merge ORIG_HEAD        <3>
>> +$ git cherry-pick --abort            <3>
>>  $ git cherry-pick -Xpatience topic^  <4>
>>  ------------
>>  <1> apply the change that would be shown by `git show topic^`.
> 

No, as far as I was able to test and from my reading of the code,
cherry-pick does not write ORIG_HEAD.

Here is a little script that demonstrates this:

```
#!/bin/sh

rm -rf test
git -c init.defaultBranch=master init test
(

cd test
echo hello>file
git add file
git commit -m initial
git branch other
echo two>>file
git commit -am two
git checkout other
echo three >>file
git commit -am three
git checkout master
# This writes ORIG_HEAD as 'two'
git reset HEAD^
git commit -a -m two-redone
# This does not
git cherry-pick other
# This shows ORIG_HEAD written by reset:
echo ORIG_HEAD is:
git log --oneline -1 ORIG_HEAD
# Whereas HEAD is 'two-redone':
echo HEAD is:
git log --oneline -1 HEAD
)
```

Looking at the code, 'git grep -p ORIG_HEAD \*.c'
reveals the only builtin that write ORIG_HEAD are 
am, merge, rebase and reset, and the only library code
that involves ORIG_HEAD is reset.c::reset_head.

Moreover, 'git grep -p [^a-z_]reset_head \*.c'
reveals that the only non-builtin user of reset.c::reset_head
is sequencer.c::create_autostash, in which the RESET_ORIG_HEAD 
flag of 'struct reset_head_opts ropts' is not set.

That is what convinced me that cherry-pick does not write ORIG_HEAD.

Thanks,

Philippe.

  reply	other threads:[~2023-01-09 13:57 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-07 19:39 [PATCH 0/5] Documentation: updates and a correction around 'ORIG_HEAD' Philippe Blain via GitGitGadget
2023-01-07 19:39 ` [PATCH 1/5] git-cherry-pick.txt: do not use 'ORIG_HEAD' in example Philippe Blain via GitGitGadget
2023-01-08  2:05   ` Junio C Hamano
2023-01-09 13:56     ` Philippe Blain [this message]
2023-01-07 19:39 ` [PATCH 2/5] git-reset.txt: mention 'ORIG_HEAD' in the Description Philippe Blain via GitGitGadget
2023-01-07 19:39 ` [PATCH 3/5] git-merge.txt: " Philippe Blain via GitGitGadget
2023-01-07 19:39 ` [PATCH 4/5] revisions.txt: be explicit about commands writing 'ORIG_HEAD' Philippe Blain via GitGitGadget
2023-01-08  2:08   ` Junio C Hamano
2023-01-09 14:00     ` Philippe Blain
2023-01-07 19:39 ` [PATCH 5/5] git-rebase.txt: add a note about 'ORIG_HEAD' being overwritten Philippe Blain via GitGitGadget
2023-01-08  2:16   ` Junio C Hamano
2023-01-09 18:22     ` Philippe Blain
2023-01-10 13:15 ` [PATCH v2 0/5] Documentation: updates and a correction around 'ORIG_HEAD' Philippe Blain via GitGitGadget
2023-01-10 13:15   ` [PATCH v2 1/5] git-cherry-pick.txt: do not use 'ORIG_HEAD' in example Philippe Blain via GitGitGadget
2023-01-10 13:15   ` [PATCH v2 2/5] git-reset.txt: mention 'ORIG_HEAD' in the Description Philippe Blain via GitGitGadget
2023-01-10 13:15   ` [PATCH v2 3/5] git-merge.txt: " Philippe Blain via GitGitGadget
2023-01-10 13:15   ` [PATCH v2 4/5] revisions.txt: be explicit about commands writing 'ORIG_HEAD' Philippe Blain via GitGitGadget
2023-01-10 13:15   ` [PATCH v2 5/5] git-rebase.txt: add a note about 'ORIG_HEAD' being overwritten Philippe Blain via GitGitGadget
2023-01-10 20:06   ` [PATCH v2 0/5] Documentation: updates and a correction around 'ORIG_HEAD' Phillip Wood
2023-01-13 17:56     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4525699c-eed5-4da6-b469-b73b87525b23@gmail.com \
    --to=levraiphilippeblain@gmail.com \
    --cc=erik@cervined.in \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=phillip.wood@dunelm.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).