verify_dotfile(): reject .git case-insensitively

We do not allow ".git" to enter into the index as a path component, because checking out the result to the working tree may causes confusion for subsequent git commands. However, on case-insensitive file systems, ".Git" or ".GIT" is the same. We should catch and prevent those, too. Note that technically we could allow this for repos on case-sensitive filesystems. But there's not much point. It's unlikely that anybody cares, and it creates a repository that is unexpectedly non-portable to other systems. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Nov 24, 2014 at 13:39 UTC cc2fc7c2f07c4a2aba5a653137ac9b489e05df43
2 files changed +4 -2
read-cache.c
+3 -2
@@ -759,9 +759,10 @@ static int verify_dotfile(const char *rest)
759 * shares the path end test with the ".." case.
760 */
761 case 'g':
762 - if (rest[1] != 'i')
762 + case 'G':
763 + if (rest[1] != 'i' && rest[1] != 'I')
764 break;
764 - if (rest[2] != 't')
765 + if (rest[2] != 't' && rest[2] != 'T')
766 break;
767 rest += 2;
768 /* fallthrough */
t/t1014-read-tree-confusing.sh
+1
@@ -27,6 +27,7 @@ done <<-\EOF
27 .
28 ..
29 .git
30 +.GIT
31 EOF
32
33 test_done