From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.1 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 1E2ED20281 for ; Mon, 22 May 2017 11:57:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758139AbdEVL5B (ORCPT ); Mon, 22 May 2017 07:57:01 -0400 Received: from mout.gmx.net ([212.227.17.22]:54437 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756155AbdEVL47 (ORCPT ); Mon, 22 May 2017 07:56:59 -0400 Received: from virtualbox ([95.208.58.16]) by mail.gmx.com (mrgmx103 [212.227.17.168]) with ESMTPSA (Nemesis) id 0LcBPV-1deRsT1qr7-00jbfx; Mon, 22 May 2017 13:56:56 +0200 Date: Mon, 22 May 2017 13:56:55 +0200 (CEST) From: Johannes Schindelin X-X-Sender: virtualbox@virtualbox To: Johannes Sixt cc: Git Mailing List Subject: Re: [PATCH 2/2] Windows: do not treat a path with backslashes as a remote's nick name In-Reply-To: <6347731f26396b1256070e02376bf3623bfb7102.1495261020.git.j6t@kdbg.org> Message-ID: References: <6347731f26396b1256070e02376bf3623bfb7102.1495261020.git.j6t@kdbg.org> User-Agent: Alpine 2.21.1 (DEB 209 2017-03-23) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Provags-ID: V03:K0:zXZcsckSLNOjDQdWswwljS2vvm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kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hi Hannes, On Sat, 20 May 2017, Johannes Sixt wrote: > Fetching from a remote using a native Windows path produces these warnings: > > C:\Temp\gittest>git fetch C:\Temp\gittest > warning: unable to access '.git/remotes/C:\Temp\gittest': Invalid argument > warning: unable to access '.git/branches/C:\Temp\gittest': Invalid argument > From C:\Temp\gittest > * branch HEAD -> FETCH_HEAD > > The functions that read the branches and remotes files are protected by > a valid_remote_nick() check. Its implementation does not take Windows > paths into account, so that the caller simply concatenates the paths, > leading to the error seen above. > > Use is_dir_sep() to check for both slashes and backslashes on Windows. > > Signed-off-by: Johannes Sixt I like this explanation. > diff --git a/remote.c b/remote.c > index 9584af366d..9501357c06 100644 > --- a/remote.c > +++ b/remote.c > @@ -649,7 +649,10 @@ static int valid_remote_nick(const char *name) > { > if (!name[0] || is_dot_or_dotdot(name)) > return 0; > - return !strchr(name, '/'); /* no slash */ > + while (*name) > + if (is_dir_sep(*name++)) /* no slash */ I understand that you simply kept the comment, yet I have to admit that I find it confusing in the post image. Something like /* remote nicknames cannot contain slashes */ (and putting it *above* the `if` line instead of appending it separated by a ) would have made it easier on me. > + return 0; > + return 1; > } > With my suggested change or without it, ACK. Ciao, Dscho