threads / discuss / 27837

git show-branch --topics and merge commits

Subject: git show-branch --topics and merge commits

## tl;dr

5 messages between Jul 17, 2011 and Jul 18, 2011.

replies: 4people: 2as markdown or json

Mike Shal· Jul 17, 2011, 23:56 UTC · lore
Hello,

I'm trying to use 'git show-branch --topics' to list the commits on a branch that are not yet in master. Normally this works fine, but after merging master up to newbranch, it comes up blank (I would expect to still see commits on newbranch that aren't on master). Eg, with a history like so:

$ git log --graph --oneline
*   94968cf Merge branch 'master' into newbranch
|\
| * 223c001 more text
* | 13766bd new
|/
* ad878b4 ok
(newbranch on the left, master on the right)
I get the following output from git show-branch:
$ git show-branch --topics master newbranch
! [master] more text
 * [newbranch] Merge branch 'master' into newbranch
--
 - [newbranch] Merge branch 'master' into newbranch
+* [master] more text

I would expect to see the 'new' commit here, since it hasn't been merged to master. The man page for git-show-branch says this should be equivalent to 'git rev-list ^master newbranch', but when I run that I get the expected output:

$ git rev-list ^master newbranch 94968cf2753b97481434f0813271659e08811177 13766bdc28df3841e25c43b53748e37f73fadb9f

So rev-list shows my merge commit and the 'new' commit, but show-branch --topics doesn't show 'new'. Is this the expected behavior? If so, what is the best way to get a list of changes on a topic branch that periodically has had the master branch merged into it?

Thanks, -Mike

Junio C Hamano· Jul 18, 2011, 02:21 UTC · re: Mike Shal · lore

Re: git show-branch --topics and merge commits

Mike Shal <marfey@gmail.com> writes:
> So rev-list shows my merge commit and the 'new' commit, but
> show-branch --topics doesn't show 'new'. Is this the expected
> behavior?

Yes, show-branch was specifically written for people with strict sense of project hygiene who do not merge into their topic from upstream (which would turn the branch from "place to hold commits on this topic" into "place to hold commits on this topic and unrelated random changes made in upstream").

Mike Shal· Jul 18, 2011, 03:37 UTC · re: Junio C Hamano · lore

Re: git show-branch --topics and merge commits

On Sun, Jul 17, 2011 at 10:21 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 13 quoted lines
> Mike Shal <marfey@gmail.com> writes:
>
>> So rev-list shows my merge commit and the 'new' commit, but
>> show-branch --topics doesn't show 'new'. Is this the expected
>> behavior?
>
> Yes, show-branch was specifically written for people with strict sense of
> project hygiene who do not merge into their topic from upstream (which
> would turn the branch from "place to hold commits on this topic" into
> "place to hold commits on this topic and unrelated random changes made in
> upstream").
>
>

Ok, makes sense. Is 'git rev-list' supposed to give the same list of commits then? In my example, rev-list shows the commit on the branch even after upstream has been merged in. My confusion comes from this line in the man page of git-show-branch:

   When given "git show-branch --topics master topic1 topic2", this
will show the revisions given by "git rev-list ^master topic1 topic2"

Thanks again, -Mike

Junio C Hamano· Jul 18, 2011, 18:14 UTC · re: Mike Shal · lore

Re: git show-branch --topics and merge commits

Mike Shal <marfey@gmail.com> writes:
> Ok, makes sense. Is 'git rev-list' supposed to give the same list of
> commits then? In my example, rev-list shows the commit on the branch
> even after upstream has been merged in.

"show-branch" was designed to stop after seeing a commit that are shared with all the branches it was given, so

	git show-branch A B
is more like
	git rev-list --left-right --boundary A...B
and not at all like
	git rev-list A..B
which is to show all commits not in A that appear in B.

Note that show-branch was invented way before the log family of commands (which rev-list is a member of) learned --left-right/--boundary/--graph options, and I personally think its graphical output mode outlived its usefulness as a stopgap measure. As its "merge-base" and "independent" modes have also been made redundant (see "git merge-base" for two options to mimic their behaviour), we may want to start thinking about deprecating the command, and the first step perhaps would be to replace its mention from the first part of the Everyday Git document with something more appropriate such as "git log".

Mike Shal· Jul 18, 2011, 23:34 UTC · re: Junio C Hamano · lore

Re: git show-branch --topics and merge commits

On Mon, Jul 18, 2011 at 2:14 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 9 quoted lines
> Note that show-branch was invented way before the log family of commands
> (which rev-list is a member of) learned --left-right/--boundary/--graph
> options, and I personally think its graphical output mode outlived its
> usefulness as a stopgap measure.  As its "merge-base" and "independent"
> modes have also been made redundant (see "git merge-base" for two options
> to mimic their behaviour), we may want to start thinking about deprecating
> the command, and the first step perhaps would be to replace its mention
> from the first part of the Everyday Git document with something more
> appropriate such as "git log".

Hmm I had no idea 'git log' was so powerful. I'll be using that from now on instead of show-branch --topics :)

Thanks for your detailed response, -Mike

← back to recent threads