]>
Commit | Line | Data |
---|---|---|
96b50cc1 JK |
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 | ||
a42643aa JK |
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" ' | |
96b50cc1 JK |
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 | ||
a42643aa | 26 | test_expect_success "reject $pretty as subtree" ' |
96b50cc1 JK |
27 | printf "040000 tree %s\t%s" "$tree" "$path" >tree && |
28 | bogus=$(git mktree <tree) && | |
29 | test_must_fail git read-tree $bogus | |
30 | ' | |
a42643aa | 31 | done <<-EOF |
96b50cc1 JK |
32 | . |
33 | .. | |
34 | .git | |
cc2fc7c2 | 35 | .GIT |
a42643aa JK |
36 | ${u200c}.Git {u200c}.Git |
37 | .gI${u200c}T .gI{u200c}T | |
38 | .GiT${u200c} .GiT{u200c} | |
96b50cc1 JK |
39 | EOF |
40 | ||
a42643aa JK |
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 | ||
96b50cc1 | 49 | test_done |