Re: [PATCH v3 2/6] worktree.c: find_worktree() learns to identify worktrees by basename
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Jun 2, 2016, 09:40 UTC
- Message-ID
- <CACsJy8B+j2im7XOV==tBtki=tOCN4k3ZHz6Jp4fq4qjqarb+ew@mail.gmail.com>
- In-Reply-To
- <xmqqr3cgycjl.fsf@gitster.mtv.corp.google.com>
On Thu, Jun 2, 2016 at 1:44 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 12 quoted lines
>> 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? I somehow thought that > normalization would happen a lot before the control reaches here. > > You'll be calling into fspathcmp() anyway; shouldn't the function > know that '/' and '\' are equivalent on some platforms, or is it > legal to only call fspathcmp() on a single path component without > directory separator?
We still need to calculate the length to compare, which could be problematic when utf-8 is involved, or some other encoding. If we always split at '/' boundary though (e.g. "abc/def/ghi", "def/ghi" or "ghi" but never "ef/ghi") then it should be ok.
-- Duy