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
Eric Sunshine <sunshine@sunshineco.com>
Date
May 9, 2013, 18:24 UTC
Message-ID
<CAPig+cS-SyANELP5N9ch2UQgsDaJmfnm0qqPBQ+71ctGDXzzYg@mail.gmail.com>
In-Reply-To
<7vk3n9dvlu.fsf@alter.siamese.dyndns.org>
On Wed, May 8, 2013 at 5:12 PM, Junio C Hamano <gitster@pobox.com> wrote:
> sha1_name.c: signal if @{-N} was a true branch nameor a detached head
s/nameor/name or/
Show 20 quoted lines
> The original API read "checkout: moving from (.*) to ..." from the
> reflog of the HEAD, and returned the substring between "from" and
> "to", but there was no way, if the substring was a 40-hex string, to
> tell if we were on a detached HEAD at that commit object, or on a
> branch whose name happened to be the 40-hex string.
>
> At this point, we cannot afford to change the format recorded in the
> reflog, so introduce a heuristics to see if the 40-hex matches the
> object name of the commit we are switching out of.  This will
> unfortunately mishandle this case:
>
>         HEX=$(git rev-parse master)
>         git checkout -b $HEX master
>         git checkout master
>
> where we were indeed on a non-detached $HEX branch (i.e. HEAD was
> pointing at refs/heads/$HEX, not storing $HEX), of course, but
> otherwise should be fairly reliable.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Previous: Jeff King
Message 7 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.