Skip to content

Commit

Permalink
verify_dotfile(): do not assume '/' is the path seperator
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Theo Niessink authored and Junio C Hamano committed Jun 8, 2011
1 parent 3bdf09c commit e0f530f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions read-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,11 +747,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.
Expand All @@ -764,7 +765,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;
Expand Down

0 comments on commit e0f530f

Please sign in to comment.