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>
Theo Niessink committed
Jun 8, 2011 at 14:04 UTC
e0f530ff8afbd252170f57e70a8609a83a7cabe1
1 file changed
+4
-3
read-cache.c
+4
-3
@@ -747,11 +747,12 @@ static int verify_dotfile(const char *rest)
747
* has already been discarded, we now test
748
* the rest.
749
*/
750
- switch (*rest) {
750
+
751
/* "." is not allowed */
752
- case '\0': case '/':
752
+ if (*rest == '\0' || is_dir_sep(*rest))
753
return 0;
754
755
+ switch (*rest) {
756
/*
757
* ".git" followed by NUL or slash is bad. This
758
* shares the path end test with the ".." case.
@@ -764,7 +765,7 @@ static int verify_dotfile(const char *rest)
765
rest += 2;
766
/* fallthrough */
767
case '.':
767
- if (rest[1] == '\0' || rest[1] == '/')
768
+ if (rest[1] == '\0' || is_dir_sep(rest[1]))
769
return 0;
770
}
771
return 1;