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

Re: Make "git status" show if on tag

From
Jeff King <peff@peff.net>
Date
Oct 9, 2013, 19:01 UTC
Message-ID
<20131009190139.GB2823@sigill.intra.peff.net>
In-Reply-To
<387b8c28.601abe13.5255a661.c2c2f@o2.pl>
On Wed, Oct 09, 2013 at 08:54:25PM +0200, bpuzon wrote:
> I was wondering if a patch that adds the tag information (something
> like what "git log --decorate" produces) to the "git status" would be
> welcome?

Do you mean when you are on a branch that also happens to point at the same commit found at a tag? Or do you mean when you have detached your HEAD at a tag (e.g., by doing "git checkout v1.0").

In the latter case, git v1.8.3 and later will print the tag name already.

If the former, I don't have a strong opinion (it is not something I would find useful, but I can see how others might). If it were not intrusive, like:

  # On branch master (v1.0)

I don't think anybody would complain. It does involve enumerating all of the refs to calculate it, which might be noticeable. OTOH, "status" is not exactly a lightweight operation already, since it has to refresh the whole index.

You might also consider just showing "git describe" output, which will show a tag if you are on it, but also show your distance to the nearest tag otherwise. It is more expensive to calculate, though.

-Peff
Previous: bpuzonNext: Jonathan Nieder
Message 2 of 3 in “Make "git status" show if on tag”
  1. bpuzonOct 9, 2013
  2. Jeff KingOct 9, 2013
  3. Jonathan NiederOct 9, 2013

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.