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, 06:05 UTC
Message-ID
<CAOeW2eH--Y_gq4jBBhd5EQRw+uuaNWrMT-Sua7CeJO-N9KHCLg@mail.gmail.com>
In-Reply-To
<7vehnacxkf.fsf@alter.siamese.dyndns.org>
On Mon, Aug 13, 2012 at 2:05 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 10 quoted lines
> Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes:
>
>> To connect to the other mail I sent on this thread (in parallel with
>> yours), do you think "git cherrry-pick HEAD HEAD~1" should apply the
>> commits in the same order as "git cherry-pick HEAD~2..HEAD" (which
>> would give the same result if passed to 'rev-list --no-walk' for a
>> linear history) or in the order specified on the command line?
>
> Definitely the latter; I do not think of any semi-reasonable excuse
> to do otherwise.
Indeed. My patches tried to fix the wrong problem.

Sorry I'm slow, but I think I'm finally starting to understand what you've been saying all along about the bug being in sequencer. I'll try to recapitulate a bit for my own and maybe others' understanding. For simplicity, let's assume a linear history with unique timestamps, but not necessarily increasing with each commit.

Currently:
 1) 'git cherry-pick A..C' picks the commits order in
  reverse "default" order
 2) 'git cherry-pick B C' picks the commits in chronological
  order
 3) 'git rev-list --reverse A..C | git cherry-pick --stdin'
  behaves just like 'git cherry-pick B C' and therefore picks
  the commits in chronological order

In cases 2) and 3), even though cherry-pick tells the revision walker not to walk, it still sorts the commits in reverse chronological order. But cherry-pick also tells the revision walker explicitly to reverse the list, so in the end, the order is chronological.

In case 2), however, the first ordering make no difference in this "limited" case (IIUC). So the "default" ordering (which would be C, then B in this case, regardless of timestamps), gets reversed and B gets applied first, followed by C.

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.

When I noticed that the order of inputs to cases 2) and 3) above was ignored, and thinking that 'git rev-list A..C | git cherry-pick --stdin' should mimic 'git cherry-pick A..C', I incorrectly thought that the error was the use of --reverse to 'git rev-list' as well as the sorting done in the no-walk case. I think completely ignored case 2) at this point.

I now think I understand that the sorting done in the no-walk case is indeed incorrect, but that the --reverse passed to rev-list is correct. Instead, the final reversal, which is currently unconditional, should not be done in the no-walk case.

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

Junio, I think it makes sense to just drop this whole series for now. I'll probably include patch 1/4 in my stalled rebase-range series instead. If I understood you correctly, you didn't have any objections to that patch.

Previous: Junio C HamanoNext: Junio C Hamano
Message 27 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.