summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-06-29 17:09:17 -0700
committerJunio C Hamano <gitster@pobox.com>2011-06-29 17:09:17 -0700
commit033c2dc4364042b9e6dbd44e82e1974f78a72567 (patch)
tree8a7dc969376cd254dd46e5f4038f9592929f8a7a /read-cache.c
parent1fd7ef2e8f6b8b67f4d3be7b9ab5bbd9d8f639ec (diff)
parente0f530ff8afbd252170f57e70a8609a83a7cabe1 (diff)
downloadgit-033c2dc4364042b9e6dbd44e82e1974f78a72567.tar.gz
Merge branch 'ef/maint-win-verify-path'
* ef/maint-win-verify-path: verify_dotfile(): do not assume '/' is the path seperator verify_path(): simplify check at the directory boundary verify_path: consider dos drive prefix real_path: do not assume '/' is the path seperator A Windows path starting with a backslash is absolute
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/read-cache.c b/read-cache.c
index 4ac9a037f4..46a9e60708 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;
@@ -753,23 +754,19 @@ int verify_path(const char *path)
{
char c;
+ if (has_dos_drive_prefix(path))
+ return 0;
+
goto inside;
for (;;) {
if (!c)
return 1;
- if (c == '/') {
+ if (is_dir_sep(c)) {
inside:
c = *path++;
- switch (c) {
- default:
- continue;
- case '/': case '\0':
- break;
- case '.':
- if (verify_dotfile(path))
- continue;
- }
- return 0;
+ if ((c == '.' && !verify_dotfile(path)) ||
+ is_dir_sep(c) || c == '\0')
+ return 0;
}
c = *path++;
}