Thread (1 message) 1 message, 1 author, 2016-06-21

Re: How to find commits unique to a branch

From: Junio C Hamano <hidden>
Date: 2016-06-21 18:44:53

Nikolaus Rath [off-list ref] writes:
On Jun 20 2016, Nikolaus Rath [off-list ref] wrote:
quoted
On Jun 20 2016, Junio C Hamano [off-list ref] wrote:
quoted
Nikolaus Rath [off-list ref] writes:
quoted
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"?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help