From: Johannes Sixt <j6t@kdbg.org>
To: Johannes Schindelin <johannes.schindelin@gmx.de>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: [PATCH v2 2/2] Windows: do not treat a path with backslashes as a remote's nick name
Date: Mon, 22 May 2017 21:01:08 +0200 [thread overview]
Message-ID: <b2fa1cff-9902-5bef-0392-1371bf1f4268@kdbg.org> (raw)
In-Reply-To: <7b1f97ff-52b7-72c3-211f-e73dce562911@kdbg.org>
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 <j6t@kdbg.org>
---
This v2 writes your suggested comment in front of the loop (not just
the 'if' because then I feel I would have to add braces).
remote.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/remote.c b/remote.c
index ad6c5424ed..1949882c10 100644
--- a/remote.c
+++ b/remote.c
@@ -645,7 +645,12 @@ static int valid_remote_nick(const char *name)
{
if (!name[0] || is_dot_or_dotdot(name))
return 0;
- return !strchr(name, '/'); /* no slash */
+
+ /* remote nicknames cannot contain slashes */
+ while (*name)
+ if (is_dir_sep(*name++))
+ return 0;
+ return 1;
}
const char *remote_for_branch(struct branch *branch, int *explicit)
--
2.13.0.55.g17b7d13330
prev parent reply other threads:[~2017-05-22 19:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-20 6:28 [PATCH 0/2] Fix warnings on access of a remote with Windows paths Johannes Sixt
2017-05-20 6:28 ` [PATCH 1/2] mingw.h: permit arguments with side effects for is_dir_sep Johannes Sixt
2017-05-22 11:52 ` Johannes Schindelin
2017-05-20 6:28 ` [PATCH 2/2] Windows: do not treat a path with backslashes as a remote's nick name Johannes Sixt
2017-05-22 11:56 ` Johannes Schindelin
2017-05-22 11:59 ` [PATCH 0/2] Fix warnings on access of a remote with Windows paths Johannes Schindelin
2017-05-22 16:36 ` Johannes Sixt
2017-05-23 10:53 ` Johannes Schindelin
2017-05-23 18:39 ` Johannes Sixt
2017-05-22 12:38 ` stefan.naewe
2017-05-22 14:01 ` Johannes Schindelin
2017-05-22 16:28 ` Johannes Sixt
2017-05-23 10:46 ` Johannes Schindelin
2017-05-23 22:08 ` Junio C Hamano
2017-05-24 5:45 ` Johannes Sixt
2017-05-25 12:00 ` [PATCH v3 2/2] Windows: do not treat a path with backslashes as a remote's nick name Johannes Sixt
2017-05-25 23:16 ` Junio C Hamano
2017-05-22 18:58 ` [PATCH v2 1/2] mingw.h: permit arguments with side effects for is_dir_sep Johannes Sixt
2017-05-22 19:01 ` Johannes Sixt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b2fa1cff-9902-5bef-0392-1371bf1f4268@kdbg.org \
--to=j6t@kdbg.org \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).