Re: [PATCH v2 2/4] branch -m: allow renaming a yet-unborn branch
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 24, 2020, 20:14 UTC
- Message-ID
- <xmqqd002jyvu.fsf@gitster.c.googlers.com>
- In-Reply-To
- <nycvar.QRO.7.76.6.2011240551050.56@tvgsbejvaqbjf.bet>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 7 quoted lines
>> > - if (!copy && rename_ref(oldref.buf, newref.buf, logmsg.buf)) >> > + if (!copy && (oldname != head || !is_null_oid(&head_oid)) && >> >> It always makes readers uneasy to see pointer comparison of two >> strings. > > Even if it was on purpose ;-)
FWIW, for fun I dropped "oldname != head ||" and tried to run the whole testsuite (plus the "branch -m src dst" form test I gave earlier), and it almost passed all of them except one, which was surprising.
> + if (!copy && !is_unborn_branch(oldname, oldref.buf) && > rename_ref(oldref.buf, newref.buf, logmsg.buf))
Yeah, a helper function makes it much more clear what is going on.
> Having said that, I fixed the `git branch -m <current-unborn> <new-name>` > use case; the fix will be part of v3.
;-)