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

Re: [PATCH v2 2/2] Doc/check-ref-format: clarify information about @{-N} syntax

From
Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Date
Dec 5, 2017, 05:20 UTC
Message-ID
<55d5598e-7c4e-c4ea-53a4-7fece0ea4d38@gmail.com>
In-Reply-To
<xmqq8teimiz3.fsf@gitster.mtv.corp.google.com>
On Tuesday 05 December 2017 12:14 AM, Junio C Hamano wrote:
Show 29 quoted lines
> Kaartic Sivaraam <kaartic.sivaraam@gmail.com> writes:
> 
>>> Stepping back a bit, the mild suspicion above says
>>>
>>>      $ git checkout HEAD^0
>>>      ... do things ...
>>>      $ git checkout -b temp
>>>      ... do more things ...
>>>      $ git checkout -B @{-1}
>>>
>>> that creates a new branch whose name is 40-hex of a commit that
>>> happens to be where we started the whole dance *is* a bug.  No sane
>>> user expects that to happen, and the last step "checkout -B @{-1}"
>>> should result in an error instead [*1*].
>>>
>>> I was wondering if "git check-ref-format --branch @{-1}", when used
>>> in place of "checkout -B @{-1}" in the above sequence,
>>
>> I guess you mean '... "git checkout -B $(git check-ref-format --branch
>> @{-1}", when used in place of "git checkout -B @{-1}" ...' ?
> 
> No you guessed wrong.  I was (and am) wondering if the last step in
> the following sequence should fail.
>>>      $ git checkout HEAD^0
>>>      ... do things ...
>>>      $ git checkout -b temp
>>>      ... do more things ...
>>>      $ git check-ref-format --branch @{-1}
> 
Ok. Now I get what you say.
> And I am leaning towards saying that it is a bug that it does not
> fail; @{-1} is a detached HEAD and not a concrete branch name in
> this case, 

It seems your thought is similar to the following thought that I expressed in [1],

-- 8< --
Show 7 quoted lines
> 
> I thought this the other way round. Rather than letting the callers
> error out when @{-N} didn't expand to a branch name, I thought we
> should not be expanding @{-N} syntax for "check-ref-format --branch" at
> all to make a "stronger guarantee" that the result is "always" a valid
> branch name. Then I thought it might be too restrictive and didn't
> mention it. So, I dunno.
-- >8 --
> so "check-ref-format --branch" should at least notice
> and say that it is a request that may lead to a nonsense next step
> (which is to create a branch with that 40-hex name).
> 

Makes sense, this should at least be noted in the Documentation. Is that what you had in mind too or do you expect 'check-ref-format' to do something else too?

[1]: https://public-inbox.org/git/1511880237.10193.5.camel@gmail.com/

--- Kaartic

Previous: Junio C HamanoNext: Kaartic Sivaraam
Message 11 of 20 in “docs: checking out using @{-N} can lead to detached state”
  1. docs: checking out using @{-N} can lead to detached stateKaartic Sivaraam, Nov 19, 2017
  2. Junio C HamanoNov 20, 2017
  3. Kaartic SivaraamNov 20, 2017
  4. 1/2 Doc/checkout: checking out using @{-N} can lead to detached stateKaartic Sivaraam, Nov 27, 2017
  5. 2/2 Doc/check-ref-format: clarify information about @{-N} syntaxKaartic Sivaraam, Nov 27, 2017
  6. Junio C HamanoNov 28, 2017
  7. Kaartic SivaraamNov 28, 2017
  8. Junio C HamanoDec 3, 2017
  9. Kaartic SivaraamDec 4, 2017
  10. Junio C HamanoDec 4, 2017
  11. Kaartic SivaraamDec 5, 2017
  12. 2/2 Doc/check-ref-format: clarify information about @{-N} syntaxKaartic Sivaraam, Nov 28, 2017
  13. Junio C HamanoDec 3, 2017
  14. Kaartic SivaraamDec 6, 2017
  15. 2/2 Doc/check-ref-format: clarify information about @{-N} syntaxKaartic Sivaraam, Dec 14, 2017
  16. Junio C HamanoDec 14, 2017
  17. Kaartic SivaraamDec 16, 2017
  18. 0/1 clarify about @{-N} syntax in check-ref-format documentationKaartic Sivaraam, Dec 16, 2017
  19. 1/1 Doc/check-ref-format: clarify information about @{-N} syntaxKaartic Sivaraam, Dec 16, 2017
  20. Junio C HamanoNov 28, 2017

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.