From: Junio C Hamano Date: Mon, 11 Mar 2019 06:20:05 GMT Subject: Re: [PATCH v5 1/1] worktree add: sanitize worktree names Message-ID: In-Reply-To: Eric Sunshine 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?