git-prompt: use here-doc instead of here-string
[git/gitster.git] / t / t1014-read-tree-confusing.sh
blob8ea8d36818bea10b227640b4974cc57f2157fa2e
1 #!/bin/sh
3 test_description='check that read-tree rejects confusing paths'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'create base tree' '
9 echo content >file &&
10 git add file &&
11 git commit -m base &&
12 blob=$(git rev-parse HEAD:file) &&
13 tree=$(git rev-parse HEAD^{tree})
16 test_expect_success 'enable core.protectHFS for rejection tests' '
17 git config core.protectHFS true
20 test_expect_success 'enable core.protectNTFS for rejection tests' '
21 git config core.protectNTFS true
24 while read path pretty; do
25 : ${pretty:=$path}
26 case "$path" in
27 *SPACE)
28 path="${path%SPACE} "
30 esac
31 test_expect_success "reject $pretty at end of path" '
32 printf "100644 blob %s\t%s" "$blob" "$path" >tree &&
33 bogus=$(git mktree <tree) &&
34 test_must_fail git read-tree $bogus
37 test_expect_success "reject $pretty as subtree" '
38 printf "040000 tree %s\t%s" "$tree" "$path" >tree &&
39 bogus=$(git mktree <tree) &&
40 test_must_fail git read-tree $bogus
42 done <<-EOF
45 .git
46 .GIT
47 ${u200c}.Git {u200c}.Git
48 .gI${u200c}T .gI{u200c}T
49 .GiT${u200c} .GiT{u200c}
50 git~1
51 .git.SPACE .git.{space}
52 .\\\\.GIT\\\\foobar backslashes
53 .git\\\\foobar backslashes2
54 .git...:alternate-stream
55 EOF
57 test_expect_success 'utf-8 paths allowed with core.protectHFS off' '
58 test_when_finished "git read-tree HEAD" &&
59 test_config core.protectHFS false &&
60 printf "100644 blob %s\t%s" "$blob" ".gi${u200c}t" >tree &&
61 ok=$(git mktree <tree) &&
62 git read-tree $ok
65 test_done