All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Daniels Umanovskis <daniels@umanovskis.se>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2 1/1] branch: introduce --show-current display option
Date: Wed, 10 Oct 2018 20:34:40 -0400	[thread overview]
Message-ID: <20181011003440.GD13853@sigill.intra.peff.net> (raw)
In-Reply-To: <20181010205432.11990-2-daniels@umanovskis.se>

On Wed, Oct 10, 2018 at 10:54:32PM +0200, Daniels Umanovskis wrote:

> When called with --show-current, git branch will print the current
> branch name and terminate. Only the actual name gets printed,
> without refs/heads. In detached HEAD state, nothing is output.

I also wondered what happens in an unborn-branch state (i.e., we are on
refs/heads/master, but have not yet made any commits).

In that case, resolve_ref_unsafe() will return the branch name, but a
null oid. And you'll print that. Which seems sensible.

> Intended both for scripting and interactive/informative use.
> Unlike git branch --list, no filtering is needed to just get the
> branch name.

We should not advertise this to be used for scripting. The git-branch
command is porcelain, and we reserve the right to change its output
between versions, or based on user config. Fortunately, there is already
a blessed way to get this in a script, which is:

  git symbolic-ref [--short] HEAD

I'm not opposed to having "branch --show-current" as a more user-facing
alternative for people who want to query the state. I do wonder if
people would want it to show extra information, like:

  - if we're detached, from where (like the normal "branch --list"
    shows)

  - are we on an unborn branch

  - are we ahead/behind an upstream (like "branch -v")

I guess that's slowly reinventing the first line of "git status -b".
Maybe that's a good thing; possibly this should just be a way to get
that data without doing the rest of git-status, and it's perhaps more
discoverable since it's part of git-branch. I dunno.

It just seems like in its current form it might be in an uncanny valley
where it is not quite scriptable plumbing, but not as informative as
other porcelain.

-Peff

  reply	other threads:[~2018-10-11  0:34 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-10 20:54 [PATCH v2 0/1] branch: introduce --show-current display option Daniels Umanovskis
2018-10-10 20:54 ` [PATCH v2 1/1] " Daniels Umanovskis
2018-10-11  0:34   ` Jeff King [this message]
2018-10-11 15:43     ` Rafael Ascensão
2018-10-11 16:36       ` Daniels Umanovskis
2018-10-11 17:51         ` Jeff King
2018-10-11 20:35           ` Rafael Ascensão
2018-10-11 20:46             ` Daniels Umanovskis
2018-10-11 20:53             ` Jeff King
2018-10-11 22:34               ` Rafael Ascensão
2018-10-11  6:54   ` Junio C Hamano
2018-10-11 17:29     ` Daniels Umanovskis
2018-10-11 17:52       ` Jeff King
2018-10-11 22:20     ` [PATCH v3] " Daniels Umanovskis
2018-10-11 23:15       ` Junio C Hamano
2018-10-11 23:31         ` Daniels Umanovskis
2018-10-12 13:33         ` [PATCH v4] " Daniels Umanovskis
2018-10-12 13:43           ` Eric Sunshine
2018-10-16 23:09             ` Junio C Hamano
2018-10-16 23:26               ` Eric Sunshine
2018-10-17 10:18                 ` Johannes Schindelin
2018-10-17 10:39                   ` Eric Sunshine
2018-10-18  9:51                     ` Johannes Schindelin
2018-10-18 14:19                       ` Eric Sunshine
2018-10-16  5:59           ` Junio C Hamano
2018-10-17  9:39           ` Rafael Ascensão
2018-10-17 17:36             ` Daniels Umanovskis
2018-10-11 22:53   ` [PATCH v2 1/1] " SZEDER Gábor
2018-10-11 22:56     ` SZEDER Gábor
2018-10-11 22:58       ` Daniels Umanovskis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181011003440.GD13853@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=daniels@umanovskis.se \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.