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

Re: [PATCH] Documentation: 'cherry' does not cope well with merges from upstream

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jul 2, 2010, 00:51 UTC
Message-ID
<20100702005147.GA5962@burratino>
In-Reply-To
<7vbpaq3glt.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
> Jonathan Nieder <jrnieder@gmail.com> writes:
Show 5 quoted lines
>> Example:
>>
>>  o---o---F---X'---G---U [upstream]
>>           \        \
>>            X----Y---M---T [topic]
[...]
Show 14 quoted lines
>> Consider the author of a different branch, also called ‘topic’, but
>> this one starts from commit G.  Some infrastructure from an existing 
>> branch is needed, so first she merges that.  Then she adds her own
>> commit.
>
> Sorry, but it is unclear to me what kind of history you have in mind at
> this point.  What "existing branch" are you talking about?  Presumably it
> is not the [topic] in an earlier example, nor it is [upstream] right?
> 
> o---o---o---o----G-------.---U [upstream]
>                   \       \ 
>                    X---Y---M---T
> 
> Something like this?

Sorry for the lack of clarity. The "existing branch" was the history ending at commit Y in the original picture. The resulting topic would have the shape of the branch labelled [topic] in my diagram.

And except for the shapes being the same, this has nothing to do with the earlier example.

What I was trying to get at with the two examples is that in histories like the above, the concept of "fork point" is not well defined. Where did topic fork from upstream? It could have been at G, or F, or any other merge-base of upstream and topic for that matter; the recorded history does not give enough information to say.

The choice of fork point might look like it is only for optimization, but it affects the semantics, too.

Example: reviving a reverted patch
 ... o---F---P---R---G---o [upstream]
                      \
                       P' [alice]

Upstream, a certain patch (P) was accepted, found to introduce horrible problems, and then reverted (R). Patch submitter Alice still believes that is a good patch, though, so she creates a branch to start work on it, cherry-picking the change (P'). ‘git cherry’ correctly reports P' as not merged upstream; that it has the same patch-id as commit P is simply irrelevant.

 $ git cherry
 + P'

Alice might merge a branch with a fork point that does not have P as an ancestor:

 ... o---o---P---R---G---o [upstream]
                      \ /
                       x
                      / \
                     o   P'
                    /     \
   ... o---o---o---F---o---M [alice]

How can ‘git cherry’ tell that the fork point was G? That knowledge determines whether P' should be considered to be merged upstream or not:

 * If the fork point was F, then the patch for P' has been applied
   upstream since then (indirectly through the merge of G).
 * If the fork point is G, then the patch for P' was upstream all
   along, and P' has no upstream analog since then.

In reality, ‘git cherry’ does not choose; instead of doing arithmetic based on fork points, it just says _no_ commit reachable from the tip of alice can be used as evidence that a patch from alice has been merged.

Plenty of other heuristics are possible, but it is hard to find a more intuitive efficient one. I suspect I would find it useful to be able to explicitly set a commit ‘prefork’ and examine all commits prefork..upstream in the search for evidence that a patch has been merged.

Previous: Junio C HamanoNext: Jonathan Nieder
Message 9 of 13 in “git cherry not marking commits with equivalent upstream”
  1. Andrew PimlottJul 1, 2010
  2. Andrew PimlottJul 1, 2010
  3. Björn SteinbrinkJul 1, 2010
  4. Andrew PimlottJul 1, 2010
  5. Documentation: 'cherry' does not cope well with merges from upstreamJonathan Nieder, Jul 1, 2010
  6. Andrew PimlottJul 1, 2010
  7. Jonathan NiederJul 1, 2010
  8. Junio C HamanoJul 1, 2010
  9. Jonathan NiederJul 2, 2010
  10. Jonathan NiederJul 2, 2010
  11. Michael J GruberJul 2, 2010
  12. Jonathan NiederJul 2, 2010
  13. Michael J GruberJul 2, 2010

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.