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

Re: [PATCH] branch: add show-tracking option

From
Junio C Hamano <gitster@pobox.com>
Date
May 16, 2013, 16:17 UTC
Message-ID
<7v1u9699x7.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CACsJy8D_5YE3w4WNvCA8-fA-y5DV2WqHULqcMYqd7X_SSh_aHw@mail.gmail.com>
Duy Nguyen <pclouds@gmail.com> writes:
Show 21 quoted lines
> On Thu, May 16, 2013 at 3:40 PM, Michael J Gruber
> <git@drmicha.warpmail.net> wrote:
>>> What if I want something in -vvvv except some in -vv? I think to avoid
>>> option explosion, maybe we can adopt --pretty=format:xxx from "git
>>> log" and let the user decideswhat (and how) to display. "pretty" code
>>> learns about alignment already, which may be useful here.
>>> --
>>> Duy
>>
>> Sure, that is the big solution we've been talking about. Unify
>> for-each-ref formats and log formats and use that. After all, "git
>> branch" in list mode really is for-each-ref, and should be transparently
>> so; same goes for "git tag". Think "git rev-list" and "git ref-list"!
>
> Again I forgot about for-each-ref. Sounds like sharing code between
> for-each-ref and branch is a good thing to do. Then just add more
> candy placeholders from git-log like %C(xx). Sounds like a fun topic.
>
>> But I guess we'll be compabeaten ;)
>
> No idea what that last word means :(

Me either, but I agree that "verbosity level" is a bad match for this kind of thing.

You need to be able to pick and choose what are shown, and the user preferences are not a linear progression that can be expressed with a simple number of 'v's.

You may not need the level of flexibility the format string gives you to choose not just what are shown but how they are shown, but if we can teach the internal machinery of for-each-ref to compute the kind of information it does not currently know, reusing the mechanism will give us the output for free.

What are the current repertoire that we can pick from?
 * HEADness
 * branch name
 * abbreviated object name of the tip commit
 * name of @{u}
   * ahead/behind [*1*]
 * title of the tip commit
So the current "-v -v" format may look something like this:
    %(headness)%(refname:short)%(objectname:short)%(upstream)%(subject)
where
    %(headness) expands to either "  " or "* "
    %(upstream) expands to "[remotes/origin/master: ahead 2, behind 47] "

The more expensive ": ahead 2, behind 47" can be omitted by spelling %(upstream:short), for example.

[Footnote]
*1* indented because this is dependent of @{u}; showing ahead/behind
    without showing @{u} would not make any sense.
Previous: Duy NguyenNext: Felipe Contreras
Message 11 of 14 in “branch: add show-tracking option”
  1. branch: add show-tracking optionFelipe Contreras, May 16, 2013
  2. Felipe ContrerasMay 16, 2013
  3. Duy NguyenMay 16, 2013
  4. Felipe ContrerasMay 16, 2013
  5. Michael J GruberMay 16, 2013
  6. Felipe ContrerasMay 16, 2013
  7. Michael J GruberMay 16, 2013
  8. Duy NguyenMay 16, 2013
  9. Michael J GruberMay 16, 2013
  10. Duy NguyenMay 16, 2013
  11. Junio C HamanoMay 16, 2013
  12. Felipe ContrerasMay 16, 2013
  13. Junio C HamanoMay 16, 2013
  14. Junio C HamanoMay 16, 2013

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.