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

Re: Feature request: status could list ref names after "HEAD detached"

From
M Hickford <mirth.hickford@gmail.com>
Date
Mar 22, 2024, 15:00 UTC
Message-ID
<CAGJzqskywQhaaG+HPWiLDqtrUE3+Zb0XuGdheJaHJMS7LqJ9xA@mail.gmail.com>
In-Reply-To
<xmqq5xxf8k9r.fsf@gitster.g>
On Thu, 21 Mar 2024 at 19:20, Junio C Hamano <gitster@pobox.com> wrote:
Show 34 quoted lines
>
> M Hickford <mirth.hickford@gmail.com> writes:
>
> > I frequently run `git status`. Sometimes HEAD is detached:
> >
> >     HEAD detached at ea601b57e
> >
> > It would be neat to include ref names here, similar to git log:
> >
> >     HEAD detached at ea601b57e (origin/main, origin/HEAD, main)
> >
> > This gives me more information before I create a new branch or switch branch.
>
> This has already moved away from the original "I want to know on
> which branch other worktrees are working" feature, but while we are
> expanding the edges...
>
> I wonder what you want to see when a detached HEAD deviated from its
> initial position (i.e., when we say "HEAD detached from", not "HEAD
> detached at", in "git status" output).  Would we still want to show
> the "--decorate" list of existing refs for the original position?
>
>     $ git checkout --detach master
>     $ git status | head -n1
>     HEAD detached at 3bd955d269
>     $ git checkout --allow-empty -m empty
>     $ git status | head -n1
>     HEAD detached from 3bd955d269
>     $ git reset --hard HEAD^
>     $ git status | head -n1
>     HEAD detached at 3bd955d269
>
> If we add "(master)" after 3bd955d269 in the above illustration, I
> wonder if it makes it too misleading.

Interesting. I hadn't appreciated the difference between "HEAD detached at" and "HEAD detached from". In the 'from' case, it'd be informative to see some measure of distance from the original position:

HEAD detached from 3bd955d269 (HEAD~1) HEAD detached [ahead 1] from 3bd955d269

Decorated with refs:

HEAD detached from 3bd955d269 (HEAD~1, master) HEAD detached [ahead 1] from 3bd955d269 (master)

Previous: Junio C Hamano
Message 3 of 3 in “Feature request: status could list ref names after "HEAD detached"”
  1. M HickfordMar 21, 2024
  2. Junio C HamanoMar 21, 2024
  3. M HickfordMar 22, 2024

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.