Skip to content

Commit e0f530f

Browse files
TaleTNgitster
authored andcommitted
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 3bdf09c commit e0f530f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

read-cache.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -747,11 +747,12 @@ static int verify_dotfile(const char *rest)
747747
* has already been discarded, we now test
748748
* the rest.
749749
*/
750-
switch (*rest) {
750+
751751
/* "." is not allowed */
752-
case '\0': case '/':
752+
if (*rest == '\0' || is_dir_sep(*rest))
753753
return 0;
754754

755+
switch (*rest) {
755756
/*
756757
* ".git" followed by NUL or slash is bad. This
757758
* shares the path end test with the ".." case.
@@ -764,7 +765,7 @@ static int verify_dotfile(const char *rest)
764765
rest += 2;
765766
/* fallthrough */
766767
case '.':
767-
if (rest[1] == '\0' || rest[1] == '/')
768+
if (rest[1] == '\0' || is_dir_sep(rest[1]))
768769
return 0;
769770
}
770771
return 1;

0 commit comments

Comments
 (0)