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

Re: [RFC] Porting builtin/branch.c to use the printing options of ref-filter.{c,h}

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 25, 2015, 18:50 UTC
Message-ID
<xmqq4mjnyzfy.fsf@gitster.dls.corp.google.com>
In-Reply-To
<CAOLa=ZRpMsFr2p=X+Z7z95W+0wGd9i5XaSDeVSmS-BUFCj6dWw@mail.gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 12 quoted lines
> I'm working on porting over the printing options of ref-filter to `git
> branch -l`.
> This is a follow up to
> http://article.gmane.org/gmane.comp.version-control.git/276377
>
> Theres a slight issue with this which I'd like to discuss about.
>
> When we use `-a` option in `git branch -l`
> It lists local branches and remotes with each having a different output format.
> This with reference to ref-filter would mean either
>
> 1. Change format in between local and remote refs

I thought the end result of consolidation would be for for-each-ref, branch -l, and tag -l to be "first collect what to show, and then show them according to a single format given". How could it be possible to switch format? It's not even like each element collected in the first phase is marked so that the second "display" phase know which one is which.

> 2. Have a format like %(if)...local check....%(then)....local branch
> format....%(else)....remote format %(end).

That, if we had a working if/then/else/end, would be a good demonstration of it.

If this were only for internal use by "branch -l", it might be overkill, but the end users with for-each-ref --format options would want to do the same thing as built-in patterns, so it is a good goal to aim at.

> I prefer the latter, but that might lead to a large format. Any suggestions?
A less ambitious option might be:
  3. Invent "%(refname:<some magic>)" format similar to
     %(refname:short) but does your thing depending on the prefix
     refs/heads/ and refs/remotes/.

but that will not work if the difference between local and remote format is not merely textual (e.g. paint them in different color).

Previous: Karthik NayakNext: Matthieu Moy
Message 2 of 6 in “[RFC] Porting builtin/branch.c to use the printing options of ref-filter.{c,h}”
  1. Karthik NayakAug 25, 2015
  2. Junio C HamanoAug 25, 2015
  3. Matthieu MoyAug 25, 2015
  4. Junio C HamanoAug 25, 2015
  5. Karthik NayakAug 26, 2015
  6. Matthieu MoyAug 26, 2015

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.