On Mon, Mar 11, 2019 at 1:36 PM Junio C Hamano <gitster@xxxxxxxxx> wrote: > while (...) > ; /* try again ... */ > > This "strip all .lock repeatedly" made me stop and think a bit; this > will never make the component empty, as the only way for this loop > to make it empty is if we have a string that match "^\(.lock)\*$" in > it, but the first dot would have already been turned into a dash, so > we'll end up with "-lock", which is not empty. Yep. I added a BUG() check anyway in worktree.c just in case something slips through in the future. > > + } > > return cp - refname; > > } > > See below for a possible further polishment. > > * The first hunk is not about this patch but a long-standing issue > after the comment was given to this function for a single level > (I do not know or care how it happened--perhaps we had a single > function that verifies multiple levels which later was split into > a caller that loops and this function that checks a single level, > and the comment for the multi-level function was left stale). > > * check_refname_component() can now try to sanitize; document it. > > * The last hunk is from Eric's comment. Thanks. -- Duy