All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
Cc: git@vger.kernel.org, Christian Couder <chriscool@tuxfamily.org>
Subject: Re: [PATCH 2/4] revisions passed to cherry-pick should be in "default" order
Date: Wed, 15 Aug 2012 10:16:09 -0700	[thread overview]
Message-ID: <7vk3x06ppi.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <CAOeW2eH--Y_gq4jBBhd5EQRw+uuaNWrMT-Sua7CeJO-N9KHCLg@mail.gmail.com> (Martin von Zweigbergk's message of "Tue, 14 Aug 2012 23:05:21 -0700")

Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes:

> So all of the above case give the right result in the end as long
> as the timestamps are chronological, and case 1) gives the right
> result regardless. The other two cases only works in most cases
> because the unexpcted sorting when no-walk is in effect
> counteracts the final reversal.

In short, if you have three commits in a row, A--B--C, with
timestamps that are not skewed, and want to replay changes of B and
then C in that order, all three you listed ends up doing the right
thing.  But if you want to apply the change C and then B:

    - "git cherry-pick A..C" is obviously not a way to do so, so we
      won't discuss it further.

    - "git cherry-pick C B" is the most natural way the user would
      want to express this request, but because of the sorting
      (i.e. commit_list_sort_by_date() in prepare_revision_walk(),
      combined with ->reverse in sequencer.c::prepare_revs()), it
      applies B and then C.  That is the real bug.

      Feeding the revs to "git cherry-pick --stdin" in the order the
      user wishes them to be applied has the same issue.

> IIUC, this could be implemented by making cherry-pick iterate
> over rev_info.pending.objects just like 'git show' does when not
> walking.

Yes, that was exactly why I said sequencer.c::prepare_revs() is
wrong to call prepare_revision_walk() unconditionally, even when
there is no revision walking involved.

I actually think your approach to place the "do not sort when we are
not walking" logic in prepare_revision_walk() makes more sense.
"show" has to look at pending.objects[] because it needs to show
objects other than commits (e.g. "git show :foo"), so there won't be
any change in its implementation with your change.  It will have to
look at pending.objects[] itself.

But "cherry-pick" and sequencer-derived commands only deal with
commits.  It would be far less error prone to let them call
get_revision() repeatedly like all other revision enumerating
commands do, than to have them go over the pending.objects[] list,
dereferencing tags and using only commits.  The resulting callers
would be more readable, too, I would think.

  reply	other threads:[~2012-08-15 17:16 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-10 20:41 cherry-pick and 'log --no-walk' and ordering Martin von Zweigbergk
2012-08-10 21:38 ` Junio C Hamano
2012-08-11  5:34   ` Martin von Zweigbergk
2012-08-11  6:28     ` Junio C Hamano
2012-08-13  6:27       ` [PATCH 0/4] " y
2012-08-13  7:17         ` Junio C Hamano
2012-08-13  7:26           ` Junio C Hamano
2012-08-13 16:09           ` Martin von Zweigbergk
2012-08-13 17:05             ` Junio C Hamano
2012-08-13 18:28               ` Martin von Zweigbergk
2012-08-13 21:31                 ` Junio C Hamano
2012-08-13 22:01                   ` Martin von Zweigbergk
2012-08-29  6:15         ` [PATCH v2 0/3] revision (no-)walking in order Martin von Zweigbergk
2012-08-29  6:15           ` [PATCH v2 1/3] teach log --no-walk=unsorted, which avoids sorting Martin von Zweigbergk
2012-08-29 17:34             ` Dan Johnson
2012-08-29 17:42               ` Junio C Hamano
2012-08-29  6:15           ` [PATCH v2 2/3] demonstrate broken 'git cherry-pick three one two' Martin von Zweigbergk
2012-08-30 21:02             ` Junio C Hamano
2012-08-29  6:15           ` [PATCH v2 3/3] cherry-pick/revert: respect order of revisions to pick Martin von Zweigbergk
2012-08-29  6:46           ` [PATCH v2 0/3] revision (no-)walking in order Junio C Hamano
2012-08-29 16:20             ` [PATCH] Martin von Zweigbergk has a new e-mail address Martin von Zweigbergk
     [not found]       ` <1344839240-17402-1-git-send-email-y>
2012-08-13  6:27         ` [PATCH 1/4] teach log --no-walk=unsorted, which avoids sorting y
2012-08-13  6:27         ` [PATCH 2/4] revisions passed to cherry-pick should be in "default" order y
2012-08-13 20:05           ` Junio C Hamano
2012-08-13 20:50             ` Martin von Zweigbergk
2012-08-13 21:05               ` Junio C Hamano
2012-08-15  6:05                 ` Martin von Zweigbergk
2012-08-15 17:16                   ` Junio C Hamano [this message]
2012-08-15 18:22                     ` Martin von Zweigbergk
2012-08-15 18:39                       ` Junio C Hamano
2012-08-15 20:50                         ` Martin von Zweigbergk
2012-08-13 20:10           ` Martin von Zweigbergk
2012-08-13 20:52             ` Junio C Hamano
2012-08-13  6:27         ` [PATCH 3/4] cherry-pick/revert: respect order of revisions to pick y
2012-08-13  6:27         ` [PATCH 4/4] cherry-pick/revert: default to topological sorting y
2012-08-13 20:23           ` Junio C Hamano
2012-08-13 21:50             ` 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=7vk3x06ppi.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=martin.von.zweigbergk@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.