read-cache: optionally disallow HFS+ .git variants
[git] / t / t1014-read-tree-confusing.sh
1 #!/bin/sh
2
3 test_description='check that read-tree rejects confusing paths'
4 . ./test-lib.sh
5
6 test_expect_success 'create base tree' '
7         echo content >file &&
8         git add file &&
9         git commit -m base &&
10         blob=$(git rev-parse HEAD:file) &&
11         tree=$(git rev-parse HEAD^{tree})
12 '
13
14 test_expect_success 'enable core.protectHFS for rejection tests' '
15         git config core.protectHFS true
16 '
17
18 while read path pretty; do
19         : ${pretty:=$path}
20         test_expect_success "reject $pretty at end of path" '
21                 printf "100644 blob %s\t%s" "$blob" "$path" >tree &&
22                 bogus=$(git mktree <tree) &&
23                 test_must_fail git read-tree $bogus
24         '
25
26         test_expect_success "reject $pretty as subtree" '
27                 printf "040000 tree %s\t%s" "$tree" "$path" >tree &&
28                 bogus=$(git mktree <tree) &&
29                 test_must_fail git read-tree $bogus
30         '
31 done <<-EOF
32 .
33 ..
34 .git
35 .GIT
36 ${u200c}.Git {u200c}.Git
37 .gI${u200c}T .gI{u200c}T
38 .GiT${u200c} .GiT{u200c}
39 EOF
40
41 test_expect_success 'utf-8 paths allowed with core.protectHFS off' '
42         test_when_finished "git read-tree HEAD" &&
43         test_config core.protectHFS false &&
44         printf "100644 blob %s\t%s" "$blob" ".gi${u200c}t" >tree &&
45         ok=$(git mktree <tree) &&
46         git read-tree $ok
47 '
48
49 test_done