From: Junio C Hamano Date: Tue, 24 Nov 2020 20:14:29 GMT Subject: Re: [PATCH v2 2/4] branch -m: allow renaming a yet-unborn branch Message-ID: In-Reply-To: Johannes Schindelin writes: >> > - 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 ` > use case; the fix will be part of v3. ;-)