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

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

From
Rafael Ascensão <rafa.almas@gmail.com>
Date
Oct 10, 2018, 14:24 UTC
Message-ID
<20181010142423.GA3390@rigel>
In-Reply-To
<xmqq8t36q1k6.fsf@gitster-ct.c.googlers.com>
On Wed, Oct 10, 2018 at 05:59:05AM +0900, Junio C Hamano wrote:
Show 7 quoted lines
>
> 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 specially.

[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 patch.

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.

Cheers, Rafael Ascensão

Previous: Eric SunshineNext: brian m. carlson
Message 5 of 9 in “branch: introduce --current display option”
  1. 0/2 branch: introduce --current display optionDaniels Umanovskis, Oct 9, 2018
  2. Junio C HamanoOct 9, 2018
  3. Eric SunshineOct 10, 2018
  4. Eric SunshineOct 10, 2018
  5. Rafael AscensãoOct 10, 2018
  6. brian m. carlsonOct 10, 2018
  7. Ævar Arnfjörð BjarmasonOct 10, 2018
  8. Daniels UmanovskisOct 10, 2018
  9. Stefan BellerOct 10, 2018

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.