]>
Commit | Line | Data |
---|---|---|
96b50cc1 JK |
1 | #!/bin/sh |
2 | ||
3 | test_description='check that read-tree rejects confusing paths' | |
98300c81 ÆAB |
4 | |
5 | TEST_PASSES_SANITIZE_LEAK=true | |
96b50cc1 JK |
6 | . ./test-lib.sh |
7 | ||
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}) | |
14 | ' | |
15 | ||
a42643aa JK |
16 | test_expect_success 'enable core.protectHFS for rejection tests' ' |
17 | git config core.protectHFS true | |
18 | ' | |
19 | ||
2b4c6efc JS |
20 | test_expect_success 'enable core.protectNTFS for rejection tests' ' |
21 | git config core.protectNTFS true | |
22 | ' | |
23 | ||
a42643aa JK |
24 | while read path pretty; do |
25 | : ${pretty:=$path} | |
2b4c6efc JS |
26 | case "$path" in |
27 | *SPACE) | |
28 | path="${path%SPACE} " | |
29 | ;; | |
30 | esac | |
a42643aa | 31 | test_expect_success "reject $pretty at end of path" ' |
96b50cc1 JK |
32 | printf "100644 blob %s\t%s" "$blob" "$path" >tree && |
33 | bogus=$(git mktree <tree) && | |
34 | test_must_fail git read-tree $bogus | |
35 | ' | |
36 | ||
a42643aa | 37 | test_expect_success "reject $pretty as subtree" ' |
96b50cc1 JK |
38 | printf "040000 tree %s\t%s" "$tree" "$path" >tree && |
39 | bogus=$(git mktree <tree) && | |
40 | test_must_fail git read-tree $bogus | |
41 | ' | |
a42643aa | 42 | done <<-EOF |
96b50cc1 JK |
43 | . |
44 | .. | |
45 | .git | |
cc2fc7c2 | 46 | .GIT |
a42643aa JK |
47 | ${u200c}.Git {u200c}.Git |
48 | .gI${u200c}T .gI{u200c}T | |
49 | .GiT${u200c} .GiT{u200c} | |
2b4c6efc JS |
50 | git~1 |
51 | .git.SPACE .git.{space} | |
52 | .\\\\.GIT\\\\foobar backslashes | |
53 | .git\\\\foobar backslashes2 | |
7c3745fc | 54 | .git...:alternate-stream |
96b50cc1 JK |
55 | EOF |
56 | ||
a42643aa JK |
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 | |
63 | ' | |
64 | ||
96b50cc1 | 65 | test_done |