git/list[1] front-page[2] threads[3] people[4] search[5] about
 

RE: [PATCH 3/3] verify_path: consider dos drive prefix

From
Theo Niessink <theo@taletn.com>
Date
Jun 8, 2011, 12:04 UTC
Message-ID
<187961B7EDE84635BD7B3C9A4EF688C3@martinic.local>
In-Reply-To
<BANLkTinTJh9oOTHi5js7n-sy8+pmMa_vtQ@mail.gmail.com>
Erik Faye-Lund wrote:
> This looks obviously correct to me. Thanks for spotting the problem.
> 
> Would you mind writing up a commit-message and supply a sign-off?
Like this you mean?
-- >8 --
Subject: [PATCH] verify_dotfile(): do not assume '/' is the path seperator
verify_dotfile() currently assumes that the path seperator is '/', but on
Windows it can also be '\\', so use is_dir_sep() instead.
    
Signed-off-by: Theo Niessink <theo@taletn.com>
---
 read-cache.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index 282c0c1..72be7cd 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -726,11 +726,12 @@ static int verify_dotfile(const char *rest)
 	 * has already been discarded, we now test
 	 * the rest.
 	 */
-	switch (*rest) {
+
 	/* "." is not allowed */
-	case '\0': case '/':
+	if (*rest == '\0' || is_dir_sep(*rest))
 		return 0;
 
+	switch (*rest) {
 	/*
 	 * ".git" followed by  NUL or slash is bad. This
 	 * shares the path end test with the ".." case.
@@ -743,7 +744,7 @@ static int verify_dotfile(const char *rest)
 		rest += 2;
 	/* fallthrough */
 	case '.':
-		if (rest[1] == '\0' || rest[1] == '/')
+		if (rest[1] == '\0' || is_dir_sep(rest[1]))
 			return 0;
 	}
 	return 1;
-- 
1.7.5.3776.g5dcaf.dirty
Previous: Erik Faye-LundNext: Erik Faye-Lund
Message 3 of 4 in “RE: [PATCH 3/3] verify_path: consider dos drive prefix”
  1. Theo NiessinkJun 8, 2011
  2. Erik Faye-LundJun 8, 2011
  3. Theo NiessinkJun 8, 2011
  4. Erik Faye-LundJun 8, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.