From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-4.1 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id B12E71F5AE for ; Fri, 11 Jun 2021 00:50:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230493AbhFKAwB (ORCPT ); Thu, 10 Jun 2021 20:52:01 -0400 Received: from mav.lukeshu.com ([104.207.138.63]:43432 "EHLO mav.lukeshu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230380AbhFKAwA (ORCPT ); Thu, 10 Jun 2021 20:52:00 -0400 X-Greylist: delayed 581 seconds by postgrey-1.27 at vger.kernel.org; Thu, 10 Jun 2021 20:52:00 EDT Received: from lukeshu-dw-thinkpad (unknown [IPv6:2601:281:8200:42e:4e34:88ff:fe48:5521]) by mav.lukeshu.com (Postfix) with ESMTPSA id A3BB780590; Thu, 10 Jun 2021 20:40:22 -0400 (EDT) Date: Thu, 10 Jun 2021 18:40:21 -0600 Message-ID: <87bl8d6xoq.wl-lukeshu@lukeshu.com> From: Luke Shumaker To: "Johannes Schindelin via GitGitGadget" Cc: git@vger.kernel.org, Luke Shumaker , Johannes Schindelin Subject: Re: [PATCH 1/2] subtree: fix the GIT_EXEC_PATH sanity check to work on Windows In-Reply-To: References: User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Thu, 10 Jun 2021 03:13:30 -0600, Johannes Schindelin via GitGitGadget wrote: > > From: Johannes Schindelin > > In 22d550749361 (subtree: don't fuss with PATH, 2021-04-27), `git > subtree` was broken thoroughly on Windows. > > The reason is that it assumes Unix semantics, where `PATH` is > colon-separated, and it assumes that `$GIT_EXEC_PATH:` is a verbatim > prefix of `$PATH`. Neither are true, the latter in particular because > `GIT_EXEC_PATH` is a Windows-style path, while `PATH` is a Unix-style > path list. > > Let's keep the original spirit, and hack together something that > unbreaks the logic on Windows. > > A more thorough fix would look at the inode of `$GIT_EXEC_PATH` and of > the first component of `$PATH`, to make sure that they are identical, > but that is even trickier to do in a portable way. > > This fixes https://github.com/git-for-windows/git/issues/3260 > > Signed-off-by: Johannes Schindelin > --- > contrib/subtree/git-subtree.sh | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh > index b06782bc7955..6bd689a6bb92 100755 > --- a/contrib/subtree/git-subtree.sh > +++ b/contrib/subtree/git-subtree.sh > @@ -5,7 +5,13 @@ > # Copyright (C) 2009 Avery Pennarun > # > > -if test -z "$GIT_EXEC_PATH" || test "${PATH#"${GIT_EXEC_PATH}:"}" = "$PATH" || ! test -f "$GIT_EXEC_PATH/git-sh-setup" > +if test -z "$GIT_EXEC_PATH" || { > + test "${PATH#"${GIT_EXEC_PATH}:"}" = "$PATH" && { > + # On Windows, PATH might be Unix-style, GIT_EXEC_PATH not > + ! type -p cygpath >/dev/null 2>&1 || > + test "${PATH#$(cygpath -au "$GIT_EXEC_PATH"):}" = "$PATH" Nit: That should have a couple more `"` in it: test "${PATH#"$(cygpath -au "$GIT_EXEC_PATH"):"}" = "$PATH" But no need to re-roll for just that. Do we also need to handle the reverse case, where PATH uses backslashes but GIT_EXEC_PATH uses forward slashes? -- Happy hacking, ~ Luke Shumaker