Re: [PATCH v3 2/6] worktree.c: find_worktree() learns to identify worktrees by basename

2016-06-05 Thread Johannes Schindelin
Hi, On Fri, 3 Jun 2016, Duy Nguyen wrote: > On Thu, Jun 2, 2016 at 11:49 PM, Junio C Hamano wrote: > > > Does "basename()" used here know '/' and '\' can both be a directory > > separator, or does worktree->path have a normalized representation of > > the path, i.e. '/' is the only directory sep

Re: [PATCH v3 2/6] worktree.c: find_worktree() learns to identify worktrees by basename

2016-06-03 Thread Junio C Hamano
Duy Nguyen writes: > basename() does (or I think so because Windows has its own version). > worktree->path always uses '/' but the command line option can come > with either '/' or '\'. Probably safest to accept both. OK. Going beyond basename() was merely "This might be an easy nice-to-have en

Re: [PATCH v3 2/6] worktree.c: find_worktree() learns to identify worktrees by basename

2016-06-03 Thread Duy Nguyen
On Thu, Jun 2, 2016 at 11:49 PM, Junio C Hamano wrote: > +static struct worktree *find_worktree_by_basename(struct worktree **list, > + const char *base_name) > +{ > + struct worktree *found = NULL; > + int nr_found = 0; > + > + for

Re: [PATCH v3 2/6] worktree.c: find_worktree() learns to identify worktrees by basename

2016-06-02 Thread Junio C Hamano
Duy Nguyen writes: > On Thu, Jun 2, 2016 at 1:44 AM, Junio C Hamano wrote: >>> We would >>> need to convert or match both '/' and '\' in "to/foo" case because of >>> Windows, so it's not much easier than basename(). >> >> I never said "easier to implement". But can this codepath get >> backslas

Re: [PATCH v3 2/6] worktree.c: find_worktree() learns to identify worktrees by basename

2016-06-02 Thread Duy Nguyen
On Thu, Jun 2, 2016 at 1:44 AM, Junio C Hamano wrote: >> We would >> need to convert or match both '/' and '\' in "to/foo" case because of >> Windows, so it's not much easier than basename(). > > I never said "easier to implement". But can this codepath get > backslashed paths in the first place?

Re: [PATCH v3 2/6] worktree.c: find_worktree() learns to identify worktrees by basename

2016-06-01 Thread Junio C Hamano
Duy Nguyen writes: >> That is, wouldn't you rather see "worktree lock to/foo" work when >> 'foo' is ambiguous but 'to/foo' is not? > > I don't know. I suppose if people have to make `basename $path` the > same because of some weird build settings, e.g. abc/git and def/git, > then this basename se

Re: [PATCH v3 2/6] worktree.c: find_worktree() learns to identify worktrees by basename

2016-06-01 Thread Duy Nguyen
On Wed, Jun 1, 2016 at 12:51 AM, Junio C Hamano wrote: > Nguyễn Thái Ngọc Duy writes: > >> This allows the user to do something like "worktree lock foo" instead of >> "worktree lock ". With completion support it could be quite >> convenient. While this base name search can be done in the same wo

Re: [PATCH v3 2/6] worktree.c: find_worktree() learns to identify worktrees by basename

2016-05-31 Thread Junio C Hamano
Nguyễn Thái Ngọc Duy writes: > This allows the user to do something like "worktree lock foo" instead of > "worktree lock ". With completion support it could be quite > convenient. While this base name search can be done in the same worktree > iteration loop, the code is split into a separate fun

[PATCH v3 2/6] worktree.c: find_worktree() learns to identify worktrees by basename

2016-05-30 Thread Nguyễn Thái Ngọc Duy
This allows the user to do something like "worktree lock foo" instead of "worktree lock ". With completion support it could be quite convenient. While this base name search can be done in the same worktree iteration loop, the code is split into a separate function for clarity. Suggested-by: Eric S