Re: [RFC/PATCH 07/11] branch: move 'current' check down to the presentation layer
- From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
- Date
- Jul 29, 2015, 10:01 UTC
- Message-ID
- <vpqk2tjmgeg.fsf@anie.imag.fr>
- In-Reply-To
- <CAOLa=ZTy+KX4K_inpDoMy+thzFdF2RF93yMEHJUExzT4OvjPww@mail.gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 17 quoted lines
> On Tue, Jul 28, 2015 at 6:39 PM, Matthieu Moy > <Matthieu.Moy@grenoble-inp.fr> wrote: >> Karthik Nayak <karthik.188@gmail.com> writes: >> >>> We check if given ref is the current branch in print_ref_list(). Move >>> this check to print_ref_item() where it is checked right before >>> printing. >> >> This means that the '*' and the different color are coded in C, hence >> it's not possible to mimick this using "git for-each-ref --format ...". >> >> I do not consider this as blocking, but I think the ultimate goal should >> be to allow this, so that all the goodies of "git branch" can be made >> available to other ref-listing commands. >> > > Not sure what you mean here.
What you already know, but probably badly explained ;-).
Eventually, the output of "git branch" should correspond to a format string (so git branch would be almost an alias for "git for-each-ref refs/heads/ --format '...'"). Internally, this would mean using show_ref_array_item instead of print_ref_item. This is what you managed to do for "git tag".
You already identified one difficulty with sha1 alignment in "git branch -v". I'm pointing out another which is that displaying the "*" in front of the current branch is currently not possible with a format string. You would need an atom like %(displayAStarIfTheBranchIsTheCurrentOne) (for which you'd need to find a short-and-sweet name ;-) ).
-- Matthieu Moy http://www-verimag.imag.fr/~moy/