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

Re: [PATCH 1/2] sha1_name.c: signal if @{-N} was a true branch nameor a detached head

From
Junio C Hamano <gitster@pobox.com>
Date
May 9, 2013, 17:08 UTC
Message-ID
<7vhaicaxo7.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20130509064607.GA11985@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> Since the point of marking the detached HEAD is to turn off things like
> "@{-1}@{u}", we would want to be generous and err on the side of
> assuming it is a branch if it _might_ be one.

I am not sure X and Y mesh well in your "Since X, we would want Y". It seems to argue for erring on the side of detached HEAD to me.

Checking the "from" name $HEX against old_sha1 is a local and cheap measure I added there for the first level of disambiguation. If they do not match, we _know_ we didn't come back from a detached HEAD state.

In order to err on the "favor branch when it could have been one", you could additionally look for the reflog .git/logs/refs/heads/$HEX when the "from" name $HEX matches old_sha1 (which is likely to be detached, but it is possible that we were on the $HEX branch when its tip was at $HEX) and making sure the tip of that $HEX branch once used to be at $HEX at the time recorded for @{-N} in the HEAD reflog in question.

That is far more expensive, though; I doubt it is worth doing.
Previous: Jeff KingNext: Jeff King
Message 5 of 7 in “sha1_name.c: signal if @{-N} was a true branch nameor a detached head”
  1. 1/2 sha1_name.c: signal if @{-N} was a true branch nameor a detached headJunio C Hamano, May 8, 2013
  2. 2/2 interpret_branch_name(): unconfuse @{-1}@{u} when @{-1} is detachedJunio C Hamano, May 8, 2013
  3. preparatory analysis of remaining @{...} issuesJunio C Hamano, May 8, 2013
  4. Jeff KingMay 9, 2013
  5. Junio C HamanoMay 9, 2013
  6. Jeff KingMay 13, 2013
  7. Eric SunshineMay 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.