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, 21:27 UTC
- Message-ID
- <vpq4mkmejsh.fsf@anie.imag.fr>
- In-Reply-To
- <CAOLa=ZRUnF12gO=AKg3E373XETqoykqOXSkPvr7DHCVrOeggAA@mail.gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 9 quoted lines
> What I was thinking of was something like this : > > struct strbuf format = STRBUF_INIT; > char c = ' '; > if (current) > c = '*'; > strbuf_addf(&format, "%c....", c, other format options...); > show_ref_array_item(item, format.buf, quote_style, 0); > strbuf_release(&format);
I think that would interact badly with verify_ref_format(). Usually, you have just one format string and call verify_ref_format() on it, not a different format string for each ref_array_item. That would probably be solvable.
Show 5 quoted lines
> This would remove the need of making the printing of the "*" to be > needed by ref-filter. As this is only needed in branch.c > > If going on what you're saying we could have a "%(starifcurrent)" atom or > something, but I don't see a general use for this.
To have a really customizeable format, you would want to allow e.g.
git branch --format '%(starifcurrent) %(objectname) %(refname)'
if the user wants to get the sha1 before the refname, and still have the star in front. It's a bit frustrating to have a hardcoded format that the user can't reproduce with the --format option, since it means you can't easily make a small variation on it.
-- Matthieu Moy http://www-verimag.imag.fr/~moy/