Re: [PATCH v3 1/1] worktree add: sanitize worktree names

2019-03-04 Thread Johannes Schindelin
Hi Duy, On Tue, 26 Feb 2019, Nguyễn Thái Ngọc Duy wrote: > diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh > index 286bba35d8..ea22207361 100755 > --- a/t/t2025-worktree-add.sh > +++ b/t/t2025-worktree-add.sh > @@ -570,4 +570,11 @@ test_expect_success '"add" an existing locked but

Re: [PATCH v3 1/1] worktree add: sanitize worktree names

2019-03-04 Thread Duy Nguyen
On Mon, Mar 04, 2019 at 06:19:15PM +0700, Duy Nguyen wrote: > On Wed, Feb 27, 2019 at 11:05 PM Jeff King wrote: > > > > On Wed, Feb 27, 2019 at 09:23:33AM -0500, Eric Sunshine wrote: > > > > > > If we just cared about saying "is this worktree name valid", I'd suggest > > > > actually constructing

Re: [PATCH v3 1/1] worktree add: sanitize worktree names

2019-03-04 Thread Duy Nguyen
On Wed, Feb 27, 2019 at 11:05 PM Jeff King wrote: > > On Wed, Feb 27, 2019 at 09:23:33AM -0500, Eric Sunshine wrote: > > > > If we just cared about saying "is this worktree name valid", I'd suggest > > > actually constructing a sample refname with the worktree name embedded > > > in it and feeding

Re: [PATCH v3 1/1] worktree add: sanitize worktree names

2019-03-02 Thread Junio C Hamano
Jeff King writes: > I agree that sanitize_refname_format() would be nice, but I'm pretty > sure it's going to end up having to duplicate many of the rules from > check_refname_format(). Which is ugly if the two ever get out of sync. > > But if we could write it in a way that keeps the actual poli

Re: [PATCH v3 1/1] worktree add: sanitize worktree names

2019-02-27 Thread Jeff King
On Wed, Feb 27, 2019 at 09:23:33AM -0500, Eric Sunshine wrote: > > If we just cared about saying "is this worktree name valid", I'd suggest > > actually constructing a sample refname with the worktree name embedded > > in it and feeding that to check_refname_format(). But because you want > > to a

Re: [PATCH v3 1/1] worktree add: sanitize worktree names

2019-02-27 Thread Eric Sunshine
On Wed, Feb 27, 2019 at 7:09 AM Jeff King wrote: > On Tue, Feb 26, 2019 at 05:58:51PM +0700, Nguyễn Thái Ngọc Duy wrote: > > Update 'worktree add' code to remove special characters to follow > > these rules. The code could replace chars with '-' more than > > necessary, but it keeps the code simpl

Re: [PATCH v3 1/1] worktree add: sanitize worktree names

2019-02-27 Thread Jeff King
On Tue, Feb 26, 2019 at 05:58:51PM +0700, Nguyễn Thái Ngọc Duy wrote: > Worktree names are based on $(basename $GIT_WORK_TREE). They aren't > significant until 3a3b9d8cde (refs: new ref types to make per-worktree > refs visible to all worktrees - 2018-10-21), where worktree name could > be part of

[PATCH v3 1/1] worktree add: sanitize worktree names

2019-02-26 Thread Nguyễn Thái Ngọc Duy
Worktree names are based on $(basename $GIT_WORK_TREE). They aren't significant until 3a3b9d8cde (refs: new ref types to make per-worktree refs visible to all worktrees - 2018-10-21), where worktree name could be part of a refname and must follow refname rules. Update 'worktree add' code to remove