Re: [PATCH v3 2/6] worktree.c: find_worktree() learns to identify worktrees by basename
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jun 5, 2016, 07:15 UTC
- Message-ID
- <alpine.DEB.2.20.1606050909240.27293@virtualbox>
- In-Reply-To
- <CACsJy8BF_KKXdMNW_aOs522wBbW9BQhbrZ_0hx+f2MCW-VPUzg@mail.gmail.com>
Hi,
On Fri, 3 Jun 2016, Duy Nguyen wrote:
Show 9 quoted lines
> On Thu, Jun 2, 2016 at 11:49 PM, Junio C Hamano <gitster@pobox.com> 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 separator? > > 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.
It is very easy to see what the Windows version of basename() does by looking at our very own test code:
https://github.com/git/git/blob/v2.8.3/test-path-utils.c#L71-L110
Short answer: basename() knows that both '/' and '\' are directory separators.
Ciao, Dscho