Skip to content

Commit 3bdf09c

Browse files
committed
verify_path(): simplify check at the directory boundary
We simply want to say "At a directory boundary, be careful with a name that begins with a dot, forbid a name that ends with the boundary character or has duplicated bounadry characters". Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 56948cb commit 3bdf09c

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

read-cache.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -784,16 +784,9 @@ int verify_path(const char *path)
784784
if (is_dir_sep(c)) {
785785
inside:
786786
c = *path++;
787-
switch (c) {
788-
default:
789-
continue;
790-
case '/': case '\0':
791-
break;
792-
case '.':
793-
if (verify_dotfile(path))
794-
continue;
795-
}
796-
return 0;
787+
if ((c == '.' && !verify_dotfile(path)) ||
788+
is_dir_sep(c) || c == '\0')
789+
return 0;
797790
}
798791
c = *path++;
799792
}

0 commit comments

Comments
 (0)