git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* cherry-pick strangeness
@ 2019-06-13 22:40 Vincent Legoll
  2019-06-13 22:56 ` Elijah Newren
  0 siblings, 1 reply; 4+ messages in thread
From: Vincent Legoll @ 2019-06-13 22:40 UTC (permalink / raw)
  To: git, Vincent Legoll - Gmail

[-- Attachment #1: Type: text/plain, Size: 939 bytes --]

Hello,

I stumbled upon a strange behavior of cherry-pick,
running the attached script yields different results
from running the same command lines manually in
an interactive shell, one after the other.

I searched the man page and found no indications
that that should act in this way. It looks like the CLI
args "--ff" & "--no-ff" or the absence of it are not
doing the same in a script as in an interactive shell.

I  asked in the IRC channel, and was asked to report
it here.

I tried to reproduce it in various environments, I
ran it in Centos 7, debian 9, ubuntu bionic & cosmic,
alpine & fedora, in docker containers, all giving the
same results. The git versions tested range from
1.8.3.1 to 2.21.0.

Trying to reproduce, I created the attached script,
which reports 3 times "SAME", whereas the case
using "--no-ff" should print "DIFF", if I'm not wrong
in reading its manpage description.

What am I missing ?

-- 
Vincent Legoll

[-- Attachment #2: repro.sh --]
[-- Type: application/x-shellscript, Size: 2290 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: cherry-pick strangeness
  2019-06-13 22:40 cherry-pick strangeness Vincent Legoll
@ 2019-06-13 22:56 ` Elijah Newren
  2019-06-14  7:26   ` Vincent Legoll
  0 siblings, 1 reply; 4+ messages in thread
From: Elijah Newren @ 2019-06-13 22:56 UTC (permalink / raw)
  To: Vincent Legoll; +Cc: Git Mailing List

On Thu, Jun 13, 2019 at 3:42 PM Vincent Legoll <vincent.legoll@gmail.com> wrote:
>
> Hello,
>
> I stumbled upon a strange behavior of cherry-pick,
> running the attached script yields different results
> from running the same command lines manually in
> an interactive shell, one after the other.
>
> I searched the man page and found no indications
> that that should act in this way. It looks like the CLI
> args "--ff" & "--no-ff" or the absence of it are not
> doing the same in a script as in an interactive shell.
>
> I  asked in the IRC channel, and was asked to report
> it here.
>
> I tried to reproduce it in various environments, I
> ran it in Centos 7, debian 9, ubuntu bionic & cosmic,
> alpine & fedora, in docker containers, all giving the
> same results. The git versions tested range from
> 1.8.3.1 to 2.21.0.
>
> Trying to reproduce, I created the attached script,
> which reports 3 times "SAME", whereas the case
> using "--no-ff" should print "DIFF", if I'm not wrong
> in reading its manpage description.
>
> What am I missing ?

When you cherry-pick a commit, it reapplies its diff on top of a
(usually different) commit, preserving the author name/email/date, but
throwing away the committer name/email/date -- instead using your
name/email and the time of the cherry-pick for the committer.  Since
you are transplanting on the same commit, and you created both the
original commit and the cherry-pick, the only thing that can be
different is the committer timestamp.  Git records timestamps down to
1-second resolution.  If you run in a script, odds are that the
original commit and the cherry-pick both run within the same second
(though not always), and thus you end up with precisely the same
commit.  When you run interactively, you take longer than a second
between commands, and thus have a different committer date which
naturally will have a different sha1sum.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: cherry-pick strangeness
  2019-06-13 22:56 ` Elijah Newren
@ 2019-06-14  7:26   ` Vincent Legoll
  2019-06-15  0:24     ` Phil Hord
  0 siblings, 1 reply; 4+ messages in thread
From: Vincent Legoll @ 2019-06-14  7:26 UTC (permalink / raw)
  To: Elijah Newren; +Cc: Git Mailing List

Hello,

On Fri, Jun 14, 2019 at 12:56 AM Elijah Newren <newren@gmail.com> wrote:
>
> On Thu, Jun 13, 2019 at 3:42 PM Vincent Legoll <vincent.legoll@gmail.com> wrote:
> >
> > What am I missing ?
>
> When you cherry-pick a commit, it reapplies its diff on top of a
> (usually different) commit, preserving the author name/email/date, but
> throwing away the committer name/email/date -- instead using your
> name/email and the time of the cherry-pick for the committer.  Since
> you are transplanting on the same commit, and you created both the
> original commit and the cherry-pick, the only thing that can be
> different is the committer timestamp.  Git records timestamps down to
> 1-second resolution.  If you run in a script, odds are that the
> original commit and the cherry-pick both run within the same second
> (though not always), and thus you end up with precisely the same
> commit.  When you run interactively, you take longer than a second
> between commands, and thus have a different committer date which
> naturally will have a different sha1sum.

Thanks for the thorough explanation.

Looks like this has nothing to do with "--[no-]ff" at all.

So if I put a "sleep 2" before each cherry-pick I won't get to see that
behavior, or if I had used something that changes the commit message
("-x", "-s" or maybe even "-S") ?

Shouldn't something about that be added to the man page to avoid
people scratch their heads ? (I can try to cook something if this is
deemed acceptable)

-- 
Vincent Legoll

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: cherry-pick strangeness
  2019-06-14  7:26   ` Vincent Legoll
@ 2019-06-15  0:24     ` Phil Hord
  0 siblings, 0 replies; 4+ messages in thread
From: Phil Hord @ 2019-06-15  0:24 UTC (permalink / raw)
  To: Vincent Legoll; +Cc: Elijah Newren, Git Mailing List

On Fri, Jun 14, 2019 at 12:29 AM Vincent Legoll
<vincent.legoll@gmail.com> wrote:
> On Fri, Jun 14, 2019 at 12:56 AM Elijah Newren <newren@gmail.com> wrote:
> > When you cherry-pick a commit, it reapplies its diff on top of a
> > (usually different) commit, preserving the author name/email/date, but
> > throwing away the committer name/email/date -- instead using your
> > name/email and the time of the cherry-pick for the committer.  Since
> > you are transplanting on the same commit, and you created both the
> > original commit and the cherry-pick, the only thing that can be
> > different is the committer timestamp.  Git records timestamps down to
> > 1-second resolution.  If you run in a script, odds are that the
> > original commit and the cherry-pick both run within the same second
> > (though not always), and thus you end up with precisely the same
> > commit.  When you run interactively, you take longer than a second
> > between commands, and thus have a different committer date which
> > naturally will have a different sha1sum.
>
> Thanks for the thorough explanation.
>
> Looks like this has nothing to do with "--[no-]ff" at all.
>
> Shouldn't something about that be added to the man page to avoid
> people scratch their heads ? (I can try to cook something if this is
> deemed acceptable)

Patches to documentation are welcome, but I'm not sure what you'd say.
Is it just a note to point out that the HEAD resulting from
cherry-pick is not guaranteed to be unique?  That seems too noisy for
something which is inconsequential to most users, to me.  But others
may disagree.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-15  0:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-13 22:40 cherry-pick strangeness Vincent Legoll
2019-06-13 22:56 ` Elijah Newren
2019-06-14  7:26   ` Vincent Legoll
2019-06-15  0:24     ` Phil Hord

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).