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

Re: Git log exclude/remotes/branches options not working as expected

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 18, 2016, 17:02 UTC
Message-ID
<xmqqzim1pp4m.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAHd499C+SACpBrOEk-V4QMKoq2egmMfYSwUN1tZBBhFOTWomRw@mail.gmail.com>
Robert Dailey <rcdailey.lists@gmail.com> writes:
Show 17 quoted lines
> I have 3 remotes registered in my clone:
>
> origin, fork, drive
>
> When I do:
>
> $ git log --oneline --decorate --graph
>
> I only want to see branches under:
>
> refs/heads/*
> refs/remotes/origin/*
>
> I tried the following:
>
> $ git log --oneline --decorate --graph --simplify-by-decoration
> --remote=origin topic1..master

I am guessing that the above is not what you actually typed and s/remote/remotes/ is what you did.

According to "git log --help":
    --remotes[=<pattern>]
        Pretend as if all the refs in refs/remotes are listed on the
        command line as <commit>. If <pattern> is given, limit
        remote-tracking branches to ones matching given shell glob. If
        pattern lacks ?, *, or [, /* at the end is implied.
So your command line is equivalent to
    $ git log --oneline --decorate --graph --simplify-by-decoration \
      refs/remotes/origin/master refs/remotes/origin/topic ... \
      topic1..master

(replace the second line with all the remote-tracking branches you have for "origin").

There is nothing that tells "--decorate" which refs to base its decoration on, so it is reasonable to expect that a commit that happens to match a tip of remote-tracking branches from other remotes are decorated as such, and I think that is what you are seeing.

> What I'm expecting is that I literally see NONE of those excluded refs
> ... How can I achieve my goals?

The decorations are added in log-tree.c::load_ref_decorations() and it does not get anything that says "I want to see decorations based on only these refs", so a short answer is that there is no canned way to do this in today's codebase.

Having said that, I would say it is a reasonable new feature to have. Another related wishlist item might say "decorate only based on tags, not branches or remote-tracking refs".

You can achieve your goals by teaching that codepath to take such new pieces of information, come up with a new command line option [*1*] and add a code to parse your command line option to either builtin/log.c or revisions.c and pass it down the callchain that leads to load_ref_decorations().

[Footnote]

*1* Unfortunately "--decorate=<option>" is already taken to specify the decoration levels, so you would need a different one.

Previous: Robert Dailey
Message 2 of 2 in “Git log exclude/remotes/branches options not working as expected”
  1. Robert DaileyOct 18, 2016
  2. Junio C HamanoOct 18, 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.