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

Re: Show all branches and ahead/behind states

From
RDRobert Dailey <rcdailey.lists@gmail.com>
Date
May 15, 2015, 14:25 UTC
Message-ID
<CAHd499Am4PFo-YRJEbQfPqtk571f4eNr_gkdy-3ATzyvBcc-jw@mail.gmail.com>
In-Reply-To
<20150514223827.GB21149@peff.net>
On Thu, May 14, 2015 at 5:38 PM, Jeff King <peff@peff.net> wrote:
Show 19 quoted lines
> On Thu, May 14, 2015 at 01:13:15PM -0500, Robert Dailey wrote:
>
>> > git for-each-ref --format '%(HEAD) %(refname:short) %(upstream:short) %(upstream:track) %(subject)' refs/heads
>>
>> Great idea. For some reason I can't apply coloring though:
>>
>> for-each-ref --format '%(HEAD) %(refname:short) %C(bold
>> blue)%(upstream:track)%C(reset)' refs/heads
>>
>> Output:
>>
>> hotfix/4.2.3.1 %C(bold blue)[ahead 1, behind 1]%C(reset)
>
> It's spelled "%C(bold blue)" in the --pretty formats, but in
> for-each-ref, it's "%(color:bold blue)". Unifying these is one of those
> things that has been on the radar for a long time, but nobody has quite
> gotten around to it.
>
> -Peff

Thanks Jeff! That definitely fixed it. I was not able to find a reference for this in the git docs, maybe I just overlooked it somewhere.

As a second query, is there a way to do column alignment? For example, I would like the ahead/behind status in one column, and the branch names left aligned in a 2nd column. I can't simply use tabs here since the length of column 1 may differ more greatly than a single tab character.

I imagine there is no built in way to do this, but just curious. I'd probably end up having to write some complicated script :-(

Thanks again you've been super helpful.
Previous: Jeff KingNext: Jeff King
Message 7 of 8 in “Show all branches and ahead/behind states”
  1. Robert DaileyMay 14, 2015
  2. Dennis KaarsemakerMay 14, 2015
  3. Robert DaileyMay 14, 2015
  4. Dennis KaarsemakerMay 14, 2015
  5. Robert DaileyMay 14, 2015
  6. Jeff KingMay 14, 2015
  7. Robert DaileyMay 15, 2015
  8. Jeff KingMay 15, 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.