git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/4] revisions passed to cherry-pick should be in "default" order

From
Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
Date
Aug 15, 2012, 18:22 UTC
Message-ID
<CAOeW2eFK+cKt9Tnh5oe74dU+f8rOOTaWk3KvE2rtUpgcOeDD7g@mail.gmail.com>
In-Reply-To
<7vk3x06ppi.fsf@alter.siamese.dyndns.org>
On Wed, Aug 15, 2012 at 10:16 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 24 quoted lines
> 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.
Exactly.
Show 6 quoted lines
> 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.
Yes, I noticed that's why "show" has to do it that way.
Show 6 quoted lines
> 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.

Makes sense, I'll try to implement it that way. I was afraid that we would need to call prepare_revision_walk() once first and then if we afterwards find out that we should not walk, we would need to call it again without the reverse option. But after looking at how rev_info.reverse is used, it seem like it's only used in get_revision(), so we can leave it either on or off during the prepare_revision_walk() and the and set appropriately before calling get_revision(), like so:

  init_revisions(&revs);
  revs.no_walk = REVISION_WALK_NO_WALK_UNSORTED;
  setup_revisions(...);
  prepare_revision_walk(&revs);
  revs.reverse = !revs.no_walk;
  // iterate over revisions
Previous: Junio C HamanoNext: Junio C Hamano
Message 29 of 37 in “cherry-pick and 'log --no-walk' and ordering”
  1. Martin von ZweigbergkAug 10, 2012
  2. Junio C HamanoAug 10, 2012
  3. Martin von ZweigbergkAug 11, 2012
  4. Junio C HamanoAug 11, 2012
  5. 0/4 Re: cherry-pick and 'log --no-walk' and orderingy@google.com, Aug 13, 2012
  6. Junio C HamanoAug 13, 2012
  7. Junio C HamanoAug 13, 2012
  8. Martin von ZweigbergkAug 13, 2012
  9. Junio C HamanoAug 13, 2012
  10. Martin von ZweigbergkAug 13, 2012
  11. Junio C HamanoAug 13, 2012
  12. Martin von ZweigbergkAug 13, 2012
  13. 0/3 revision (no-)walking in orderMartin von Zweigbergk, Aug 29, 2012
  14. 1/3 teach log --no-walk=unsorted, which avoids sortingMartin von Zweigbergk, Aug 29, 2012
  15. Dan JohnsonAug 29, 2012
  16. Junio C HamanoAug 29, 2012
  17. 2/3 demonstrate broken 'git cherry-pick three one two'Martin von Zweigbergk, Aug 29, 2012
  18. Junio C HamanoAug 30, 2012
  19. 3/3 cherry-pick/revert: respect order of revisions to pickMartin von Zweigbergk, Aug 29, 2012
  20. Junio C HamanoAug 29, 2012
  21. Martin von Zweigbergk has a new e-mail addressMartin von Zweigbergk, Aug 29, 2012
  22. 1/4 teach log --no-walk=unsorted, which avoids sortingy@google.com, Aug 13, 2012
  23. 2/4 revisions passed to cherry-pick should be in "default" ordery@google.com, Aug 13, 2012
  24. Junio C HamanoAug 13, 2012
  25. Martin von ZweigbergkAug 13, 2012
  26. Junio C HamanoAug 13, 2012
  27. Martin von ZweigbergkAug 15, 2012
  28. Junio C HamanoAug 15, 2012
  29. Martin von ZweigbergkAug 15, 2012
  30. Junio C HamanoAug 15, 2012
  31. Martin von ZweigbergkAug 15, 2012
  32. Martin von ZweigbergkAug 13, 2012
  33. Junio C HamanoAug 13, 2012
  34. 3/4 cherry-pick/revert: respect order of revisions to picky@google.com, Aug 13, 2012
  35. 4/4 cherry-pick/revert: default to topological sortingy@google.com, Aug 13, 2012
  36. Junio C HamanoAug 13, 2012
  37. Junio C HamanoAug 13, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.