Re: [PATCH v5 1/1] worktree add: sanitize worktree names
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Mar 11, 2019, 09:24 UTC
- Message-ID
- <CACsJy8CqN=Uu-Fez7T9evazitVopXt2dkQ1rGzKwh94tdiUdvA@mail.gmail.com>
- In-Reply-To
- <xmqqbm2ikk4q.fsf@gitster-ct.c.googlers.com>
On Mon, Mar 11, 2019 at 1:20 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 20 quoted lines
>
> Eric Sunshine <sunshine@sunshineco.com> writes:
>
> >> case 2:
> >> + if (last == '.') { /* Refname contains "..". */
> >> + if (sanitized)
> >> + sanitized->len--; /* collapse ".." to single "." */
> >
> > I think this needs to be:
> >
> > strbuf_setlen(sanitized, sanitized->len - 1);
> >
> > to ensure that NUL-terminator ends up in the correct place if this "."
> > is the very last character in 'refname'. (Otherwise, the NUL will
> > remain after the second ".", thus ".." won't be collapsed to "." at
> > all.)
>
> True. Why doesn't it do the similar "replace with -" it does for
> other unfortunate characters, though?
>I think Jeff saw an opportunity to keep it cleaner ("." looks better than ".-") and took it.
-- Duy