
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>
34 lines
690 B
Bash
Executable File
34 lines
690 B
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='check that read-tree rejects confusing paths'
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'create base tree' '
|
|
echo content >file &&
|
|
git add file &&
|
|
git commit -m base &&
|
|
blob=$(git rev-parse HEAD:file) &&
|
|
tree=$(git rev-parse HEAD^{tree})
|
|
'
|
|
|
|
while read path; do
|
|
test_expect_success "reject $path at end of path" '
|
|
printf "100644 blob %s\t%s" "$blob" "$path" >tree &&
|
|
bogus=$(git mktree <tree) &&
|
|
test_must_fail git read-tree $bogus
|
|
'
|
|
|
|
test_expect_success "reject $path as subtree" '
|
|
printf "040000 tree %s\t%s" "$tree" "$path" >tree &&
|
|
bogus=$(git mktree <tree) &&
|
|
test_must_fail git read-tree $bogus
|
|
'
|
|
done <<-\EOF
|
|
.
|
|
..
|
|
.git
|
|
.GIT
|
|
EOF
|
|
|
|
test_done
|