Skip to content

Commit

Permalink
verify_dotfile(): reject .git case-insensitively
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
peff authored and gitster committed Dec 17, 2014
1 parent 96b50cc commit cc2fc7c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions read-cache.c
Expand Up @@ -759,9 +759,10 @@ static int verify_dotfile(const char *rest)
* shares the path end test with the ".." case.
*/
case 'g':
if (rest[1] != 'i')
case 'G':
if (rest[1] != 'i' && rest[1] != 'I')
break;
if (rest[2] != 't')
if (rest[2] != 't' && rest[2] != 'T')
break;
rest += 2;
/* fallthrough */
Expand Down
1 change: 1 addition & 0 deletions t/t1014-read-tree-confusing.sh
Expand Up @@ -27,6 +27,7 @@ done <<-\EOF
.
..
.git
.GIT
EOF

test_done

0 comments on commit cc2fc7c

Please sign in to comment.