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

Re: [PATCH] patch-ids: handle duplicate hashmap entries

From
Jeff King <peff@peff.net>
Date
Jan 13, 2021, 20:33 UTC
Message-ID
<X/9ZNM9KxZaQ2it+@coredump.intra.peff.net>
In-Reply-To
<xmqq7dogy4dx.fsf@gitster.c.googlers.com>
On Wed, Jan 13, 2021 at 12:21:30PM -0800, Junio C Hamano wrote:
Show 15 quoted lines
> > I suspect for most operations we care less about "remove all
> > cherry-picks from both sides", but rather "give me one side, omitting
> > commits that are already on the other side" (because you want to rebase
> > or cherry-pick some subset).
> 
> Yes again.  It means "--cherry-pick" inherently is not symmetric.
> One side is the reference side (i.e. mainline), and the goal is to
> remove from the other side what is in the reference side.
> 
> What we are seeing in this discussion is that "--cherry-pick" and
> symmetric difference do not conceptually play well together.
> 
> But the behaviour with the patch makes the most sense when
> cherry-pick is applied to a symmetric difference (provided that
> doing so makes sense in the first place, that is).

I didn't realize --cherry-pick would work without a symmetric difference. The documentation says:

  Omit any commit that introduces the same change as another commit on
  the “other side” when the set of commits are limited with symmetric
  difference.
And indeed, I think it silently does nothing with:
  git rev-list --cherry-pick A..B
(because there is nothing on the "other" side to match).

So you do need some symmetric difference in order to define the two sets, but you might only want to see one of the sides. And that is basically what --cherry does. But having looked at the implementation of cherry_pick_list(), it is quite happy to swap the sides internally. I guess if we were going to make the output unsymmetric, the first thing would be to stop doing that swap. :)

For the specifics of reverts and replays, though, I think the weirdness has nothing to do with left/right, or showing one side. It's the mismatched count. So if we were to make any change, it would be to keep a count of how many times each commit appears on the other side, and cancel them one for one.

I.e., this:
  o--M--W--M--o--
   \
    o--M--o---
might plausibly want to show "M" once on the upper branch. But:
  o--M--W--M--o--
   \
    o--M--W--M--o--
should never show M, I wouldn't think.

I'm not sure if that would be violating what existing callers expect from "--cherry-pick", though (i.e., if it would need another name, or an extra option to trigger).

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 14 of 15 in “rev-list with multiple commits sharing same patch-id”
  1. Arnaud MorinJan 9, 2021
  2. Arnaud MorinJan 11, 2021
  3. Christian CouderJan 11, 2021
  4. Arnaud MorinJan 11, 2021
  5. Jeff KingJan 12, 2021
  6. Jeff KingJan 12, 2021
  7. Arnaud MorinJan 12, 2021
  8. patch-ids: handle duplicate hashmap entriesJeff King, Jan 12, 2021
  9. Arnaud MorinJan 12, 2021
  10. Junio C HamanoJan 12, 2021
  11. Arnaud MorinJan 13, 2021
  12. Jeff KingJan 13, 2021
  13. Junio C HamanoJan 13, 2021
  14. Jeff KingJan 13, 2021
  15. Junio C HamanoJan 13, 2021

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.