Skip to content

Commit e19e5e6

Browse files
committed
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 <[email protected]>
1 parent 41a8092 commit e19e5e6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

read-cache.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -810,17 +810,17 @@ static int verify_dotfile(const char *rest)
810810

811811
switch (*rest) {
812812
/*
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.
815814
*/
816815
case 'g':
817816
case 'G':
818817
if (rest[1] != 'i' && rest[1] != 'I')
819818
break;
820819
if (rest[2] != 't' && rest[2] != 'T')
821820
break;
822-
rest += 2;
823-
/* fallthrough */
821+
if (rest[3] == '\0' || is_dir_sep(rest[3]))
822+
return 0;
823+
break;
824824
case '.':
825825
if (rest[1] == '\0' || is_dir_sep(rest[1]))
826826
return 0;

0 commit comments

Comments
 (0)