Re: [PATCH v2] branch -D: allow - as abbreviation of '@{-1}'
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Mar 22, 2016, 18:57 UTC
- Message-ID
- <CAPig+cSuRkBxUNY_nA4Ha6g3k-8VtmfFM80+gTmdM23n4e6Uxg@mail.gmail.com>
- In-Reply-To
- <xmqqwpouigin.fsf@gitster.mtv.corp.google.com>
On Tue, Mar 22, 2016 at 1:12 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 13 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>> I _think_ strbuf_branchname() leaves "@{-<N>}" when you do not have
>> enough branch switches in the reflog, so perhaps ...
>
> This is a tangent, but the value returned from strbuf_branchname()
> is not well documented, and nobody looks at it. It might not be a
> bad idea to change the return value from the function in such a way
> that it can signal "I saw @{-<N>} syntax but there weren't enough
> branch switches" and also "I saw branch@{upstream} syntax but that
> branch does not have an upstream configured for it" to its callers.
>
> That way, the suggested "perhaps like this..." patch does not have
> to do an ugly hack: if (starts_with(bname.buf, "@{-")).In case it's not clear, when Junio says "this is a tangent", he is not saying that he expects you to make this change as part of your microproject. Rather, he's just putting it out there as "low hanging fruit" if someone wants a small project to tackle (and indeed, it might make a reasonable microproject itself).