verify_path: drop clever fallthrough
We check ".git" and ".." in the same switch statement, and fall through the cases to share the end-of-component check. While this saves us a line or two, it makes modifying the function much harder. Let's just write it out. Signed-off-by: Jeff King <peff@peff.net>
Jeff King committed
May 13, 2018 at 13:00 UTC
e19e5e66d691bdeeeb5e0ed2ffcecdd7666b0d7b
1 file changed
+4
-4
read-cache.c
+4
-4
@@ -810,8 +810,7 @@ static int verify_dotfile(const char *rest)
810
811
switch (*rest) {
812
/*
813
- * ".git" followed by NUL or slash is bad. This
814
- * shares the path end test with the ".." case.
813
+ * ".git" followed by NUL or slash is bad.
814
*/
815
case 'g':
816
case 'G':
@@ -819,8 +818,9 @@ static int verify_dotfile(const char *rest)
818
break;
819
if (rest[2] != 't' && rest[2] != 'T')
820
break;
822
- rest += 2;
823
- /* fallthrough */
821
+ if (rest[3] == '\0' || is_dir_sep(rest[3]))
822
+ return 0;
823
+ break;
824
case '.':
825
if (rest[1] == '\0' || is_dir_sep(rest[1]))
826
return 0;