Re: [PATCH v2 2/2] Doc/check-ref-format: clarify information about @{-N} syntax
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 4, 2017, 18:44 UTC
- Message-ID
- <xmqq8teimiz3.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <1512408328.15792.5.camel@gmail.com>
Kaartic Sivaraam <kaartic.sivaraam@gmail.com> writes:
Show 18 quoted lines
>> 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.
Show 5 quoted lines
>> $ git checkout HEAD^0
>> ... do things ...
>> $ git checkout -b temp
>> ... do more things ...
>> $ git check-ref-format --branch @{-1}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, 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).