Web lists-archives.com

Re: [PATCH 0/2] branch: introduce --current display option

On Wed, Oct 10, 2018 at 05:59:05AM +0900, Junio C Hamano wrote:
> But I do not think that is what is going on.  There is "--list" that
> lists branches whose name match given patterns, and at the end-user
> level (I haven't seen the implementation) this is another mode of
> that operation that limits itself to the one that is currently
> checked out

Given the idea that showing the current branch is a particular case of
what --list does, one option could be to treat the 'HEAD' pattern

[After writing another version of this email, I found that we
already special case the pattern 'HEAD']

$git branch; already treats the 'HEAD' pattern specially to print
something like: "* (HEAD detached at e83c516331)" when the HEAD is
detached. But returns without output when the HEAD is attached.

We could make $git branch --list HEAD; print the current branch
paralleling nicely with what $git rev-parse --abrev-ref HEAD; already
does when given attached and detached HEAD; But keeping the perks of the
more human-readable output (color, * marker, formatting, etc).

Since the output of git branch isn't meant to be parsable, changing this
behaviour shouldn't affect users, and introduce the feature without the
need of new options.

But I suspect this approach may be diverging from the spirit of this

>From my time spent on #git, I find that the concept of 'HEAD' is
something that many new users misunderstand. So, if the original
motivation behind this patch is to be able to determine the current
branch without using the concept of 'HEAD', my suggestion falls short.

Rafael Ascensão