Skip to content

Commit cc2fc7c

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 96b50cc commit cc2fc7c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

read-cache.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,9 +759,10 @@ static int verify_dotfile(const char *rest)
759759
* shares the path end test with the ".." case.
760760
*/
761761
case 'g':
762-
if (rest[1] != 'i')
762+
case 'G':
763+
if (rest[1] != 'i' && rest[1] != 'I')
763764
break;
764-
if (rest[2] != 't')
765+
if (rest[2] != 't' && rest[2] != 'T')
765766
break;
766767
rest += 2;
767768
/* fallthrough */

t/t1014-read-tree-confusing.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ done <<-\EOF
2727
.
2828
..
2929
.git
30+
.GIT
3031
EOF
3132

3233
test_done

0 commit comments

Comments
 (0)