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>
Junio C Hamano committed
Jun 6, 2011 at 20:49 UTC
3bdf09c7f555d553b4fee00c00c760b546812d4f
1 file changed
+3
-10
read-cache.c
+3
-10
@@ -784,16 +784,9 @@ int verify_path(const char *path)
784
if (is_dir_sep(c)) {
785
inside:
786
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;
790
}
791
c = *path++;
792
}