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

From: Matthieu Moy <[email-masked]>
Date: Wed, 26 Aug 2015 11:02:18 +0200

Karthik Nayak <[email-masked]> writes:

> It's more than just colors. The whole format changes.
>
> $ git branch -a
> For local:
> "%(if)%(HEAD)%(then)%(HEAD) %(color:green)%(refname:short)%(else)
> %(refname:short)%(end)"
> For remote:
> "  remotes/%(color:red)%(refname:short)%(color:reset)%(if)%(symref)%(then)
> -> %(symref:short)%(end)"

I think both versions are not so different. You have %(if) on one format
strings that would be disabled by construction on the second. For
example, adding %(if)%(HEAD)%(then)%(HEAD) at the start of the
format-string for remotes would be a no-op, right?

And in case a local branch is a symref, "git branch" displays "-> ..."
both for local and for remotes. You just normally don't have local
symref branches other than HEAD, but I tried:

$ git checkout -b branch
$ cat .git/HEAD > .git/refs/heads/symref
$ git branch -a
* branch
  master
  symref -> branch

The only remaining difference I see are the "remotes/" prefix and
colors.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/