From mboxrd@z Thu Jan 1 00:00:00 1970 From: Duy Nguyen Subject: Re: [PATCH v3 2/6] worktree.c: find_worktree() learns to identify worktrees by basename Date: Thu, 2 Jun 2016 16:40:35 +0700 Message-ID: References: <20160522104341.656-1-pclouds@gmail.com> <20160530104939.28407-1-pclouds@gmail.com> <20160530104939.28407-3-pclouds@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Cc: Git Mailing List , Eric Sunshine , =?UTF-8?Q?Reto_Habl=C3=BCtzel?= , Mike Rappazzo To: Junio C Hamano X-From: git-owner@vger.kernel.org Thu Jun 02 11:41:13 2016 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1b8P7p-0001Nc-11 for gcvg-git-2@plane.gmane.org; Thu, 02 Jun 2016 11:41:13 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932651AbcFBJlI (ORCPT ); Thu, 2 Jun 2016 05:41:08 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:34600 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932440AbcFBJlG (ORCPT ); Thu, 2 Jun 2016 05:41:06 -0400 Received: by mail-io0-f196.google.com with SMTP id l9so5820784ioe.1 for ; Thu, 02 Jun 2016 02:41:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=GI79fdOE///CsBNiWi6vm5WTphDrFDGSihDOTylA8LQ=; b=LFVaCexnJT7d2WjjAidbeDr77lMiC/lnF3bX+Qc/vme8MUx+o+mkcEuQ1aunMht3AQ nDx9qxMKp/jbNWJEmJ9EpkE0PvKJKDDUZdqOMY/jB4TeoMR/6FQdu/vHLiKe9bWPvuEp TeZqxOh41U4mEhMyAGkMIWus62osivpHwd2ZdwbKdlSmpVUWBC8GjY+w3SotIvnyDUsH b11gmOObuNkWfiolB+oNZsoJK4uubZChWrRWL7BUOCCsN1lu32aO6qU3h1tNY1Ru2nm7 +lgMvL1NIcJb+p1Z/dhBmxh7s8yycYrl9YkTNKyP99gq2ysBDQMibrCtmdFVgEUFLwxP 8ewg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=GI79fdOE///CsBNiWi6vm5WTphDrFDGSihDOTylA8LQ=; b=R1G/nJBBMiha9SjWsGJj0c+7UrvNFlIHJLuEzU/wfEVZWBHn0eBkj8XZhxLVvrvb2b GOKzNSY+O308iUS8s/Cm+luTPm2AIUo2GBQ/Hn6oIneDw3ITU1yfDht+RyqGyo55IbRE GGtJVg7JwpTXj0mz3fnA8ejZJamFscucJr71umBzEZTS5GazVGUUyNhHnLhizbUm1h0T lzdN1+ic9+5WOujRS/gvv+xBzHWMFMB/6ZXZnKmpPTym8eq/08lE+XO/YxTwdKOH/Z3q 3NE+/8PKqx5xoIsdR/KEU4VddygcvMNqHX6d112136H603Gb46MsOOaM32qeopvzwxmB cODg== X-Gm-Message-State: ALyK8tJdh5ETrg3wPp/5uDxbT5Bp9KaGp7+dt2BFuvStZMlv3js9QtQ78SB12/jPa0jHzTOeyMp6xVigIeqh5Q== X-Received: by 10.107.22.131 with SMTP id 125mr2015415iow.128.1464860465055; Thu, 02 Jun 2016 02:41:05 -0700 (PDT) Received: by 10.64.173.167 with HTTP; Thu, 2 Jun 2016 02:40:35 -0700 (PDT) In-Reply-To: Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: 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? 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