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

Re: How to find commits unique to a branch

From
Nikolaus Rath <nikolaus@rath.org>
Date
Jun 22, 2016, 16:38 UTC
Message-ID
<87mvmdgowj.fsf@thinkpad.rath.org>
In-Reply-To
<xmqq7fdiqtqv.fsf@gitster.mtv.corp.google.com>
On Jun 21 2016, Junio C Hamano <gitster@pobox.com> wrote:
Show 60 quoted lines
> Nikolaus Rath <Nikolaus@rath.org> writes:
>
>> On Jun 20 2016, Nikolaus Rath <Nikolaus@rath.org> wrote:
>>> On Jun 20 2016, Junio C Hamano <gitster@pobox.com> wrote:
>>>> Nikolaus Rath <Nikolaus@rath.org> writes:
>>>>
>>>>> What's the best way to find all commits in a branch A that have not been
>>>>> cherry-picked from (or to) another branch B?
>>>>>
>>>>> I think I could format-patch all commits in every branch into separate
>>>>> files, hash the Author and Date of each files, and then compare the two
>>>>> lists. But I'm hoping there's a way to instead have git do the
>>>>> heavy-lifting?
>>>>
>>>> "git cherry" perhaps?
>>>
>>> That seems to work only the "wrong way around". I have a tag
>>> fuse_3_0_start, which is the common ancestor to "master" and
>>> "fuse_2_9_bugfix". I'd like to find all the commits from fuse_3_0_start
>>> to master that have not been cherry-picked into fuse_2_9_bugfix.
>
> Hmm, so the topology roughly would look like:
>
>             A'--B'--D' 2fix
>            /
>           o---A---B---C---D---E---F master
> 	3start
>
> And you want to find commits in 3start..master that do not have
> equivalent in 3start..2fix
>
> "git cherry --help" starts like this:
>
>     NAME
>            git-cherry - Find commits yet to be applied to upstream
>
>     SYNOPSIS
>            git cherry [-v] [<upstream> [<head> [<limit>]]]
>
>     DESCRIPTION
>            Determine whether there are commits in <head>..<upstream>
>            that are equivalent to those in the range <limit>..<head>.
>
> Applying that to our picture, we want to find commits yet to be
> applied to 2fix, and do so by comparing the commits between
> 3start..master and 3start..2fix.
>
> I find that the first sentence of the description is fuzzy
> ("Determine whether" would imply that you would get "Yes/No" but
> what we want is "here are the commits that do not have counterpart
> in 2fix"), but we already know <upstream> corresponds to 2fix
> (i.e. we are finding ones yet to be applied to there, which can be
> inferred from the NAME line), so <head> must be 'master' That means
> that <limit> corresponds to 3start, and we will be comparing commits
> in two ranges:
>
>     master..2fix (i e. <head>..<upstream>, which is the same thing as 3start..2fix)
>     3start..master (i.e. <limit>..<head>)
>
> So perhaps "git cherry -v 2fix master 3start"?

This works, thanks! I don't quite understand why though. I started by saying that I want to know which commits in master are have been cherry picked after 3start was branched to 2fix, so <limit>..<head> must be 3start..2fix, which only leaves "master" as <upstream>. What's wrong with that thought?

Best, -Nikolaus

-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 9 in “How to find commits unique to a branch”
  1. Nikolaus RathJun 20, 2016
  2. Junio C HamanoJun 20, 2016
  3. Nikolaus RathJun 20, 2016
  4. Michael J GruberJun 21, 2016
  5. Nikolaus RathJun 22, 2016
  6. Nikolaus RathJun 21, 2016
  7. Junio C HamanoJun 21, 2016
  8. Nikolaus RathJun 22, 2016
  9. Junio C HamanoJun 22, 2016

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.