2014-11-25 02:37:56 +08:00
|
|
|
#!/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})
|
|
|
|
'
|
|
|
|
|
2014-12-16 07:15:20 +08:00
|
|
|
test_expect_success 'enable core.protectHFS for rejection tests' '
|
|
|
|
git config core.protectHFS true
|
|
|
|
'
|
|
|
|
|
2014-12-17 06:46:59 +08:00
|
|
|
test_expect_success 'enable core.protectNTFS for rejection tests' '
|
|
|
|
git config core.protectNTFS true
|
|
|
|
'
|
|
|
|
|
2014-12-16 07:15:20 +08:00
|
|
|
while read path pretty; do
|
|
|
|
: ${pretty:=$path}
|
2014-12-17 06:46:59 +08:00
|
|
|
case "$path" in
|
|
|
|
*SPACE)
|
|
|
|
path="${path%SPACE} "
|
|
|
|
;;
|
|
|
|
esac
|
2014-12-16 07:15:20 +08:00
|
|
|
test_expect_success "reject $pretty at end of path" '
|
2014-11-25 02:37:56 +08:00
|
|
|
printf "100644 blob %s\t%s" "$blob" "$path" >tree &&
|
|
|
|
bogus=$(git mktree <tree) &&
|
|
|
|
test_must_fail git read-tree $bogus
|
|
|
|
'
|
|
|
|
|
2014-12-16 07:15:20 +08:00
|
|
|
test_expect_success "reject $pretty as subtree" '
|
2014-11-25 02:37:56 +08:00
|
|
|
printf "040000 tree %s\t%s" "$tree" "$path" >tree &&
|
|
|
|
bogus=$(git mktree <tree) &&
|
|
|
|
test_must_fail git read-tree $bogus
|
|
|
|
'
|
2014-12-16 07:15:20 +08:00
|
|
|
done <<-EOF
|
2014-11-25 02:37:56 +08:00
|
|
|
.
|
|
|
|
..
|
|
|
|
.git
|
2014-11-25 02:39:12 +08:00
|
|
|
.GIT
|
2014-12-16 07:15:20 +08:00
|
|
|
${u200c}.Git {u200c}.Git
|
|
|
|
.gI${u200c}T .gI{u200c}T
|
|
|
|
.GiT${u200c} .GiT{u200c}
|
2014-12-17 06:46:59 +08:00
|
|
|
git~1
|
|
|
|
.git.SPACE .git.{space}
|
|
|
|
.\\\\.GIT\\\\foobar backslashes
|
|
|
|
.git\\\\foobar backslashes2
|
2014-11-25 02:37:56 +08:00
|
|
|
EOF
|
|
|
|
|
2014-12-16 07:15:20 +08:00
|
|
|
test_expect_success 'utf-8 paths allowed with core.protectHFS off' '
|
|
|
|
test_when_finished "git read-tree HEAD" &&
|
|
|
|
test_config core.protectHFS false &&
|
|
|
|
printf "100644 blob %s\t%s" "$blob" ".gi${u200c}t" >tree &&
|
|
|
|
ok=$(git mktree <tree) &&
|
|
|
|
git read-tree $ok
|
|
|
|
'
|
|
|
|
|
2014-11-25 02:37:56 +08:00
|
|
|
test_done
|