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 | ||
2b4c6efc JS |
18 | test_expect_success 'enable core.protectNTFS for rejection tests' ' |
19 | git config core.protectNTFS true | |
20 | ' | |
21 | ||
a42643aa JK |
22 | while read path pretty; do |
23 | : ${pretty:=$path} | |
2b4c6efc JS |
24 | case "$path" in |
25 | *SPACE) | |
26 | path="${path%SPACE} " | |
27 | ;; | |
28 | esac | |
a42643aa | 29 | test_expect_success "reject $pretty at end of path" ' |
96b50cc1 JK |
30 | printf "100644 blob %s\t%s" "$blob" "$path" >tree && |
31 | bogus=$(git mktree <tree) && | |
32 | test_must_fail git read-tree $bogus | |
33 | ' | |
34 | ||
a42643aa | 35 | test_expect_success "reject $pretty as subtree" ' |
96b50cc1 JK |
36 | printf "040000 tree %s\t%s" "$tree" "$path" >tree && |
37 | bogus=$(git mktree <tree) && | |
38 | test_must_fail git read-tree $bogus | |
39 | ' | |
a42643aa | 40 | done <<-EOF |
96b50cc1 JK |
41 | . |
42 | .. | |
43 | .git | |
cc2fc7c2 | 44 | .GIT |
a42643aa JK |
45 | ${u200c}.Git {u200c}.Git |
46 | .gI${u200c}T .gI{u200c}T | |
47 | .GiT${u200c} .GiT{u200c} | |
2b4c6efc JS |
48 | git~1 |
49 | .git.SPACE .git.{space} | |
50 | .\\\\.GIT\\\\foobar backslashes | |
51 | .git\\\\foobar backslashes2 | |
96b50cc1 JK |
52 | EOF |
53 | ||
a42643aa JK |
54 | test_expect_success 'utf-8 paths allowed with core.protectHFS off' ' |
55 | test_when_finished "git read-tree HEAD" && | |
56 | test_config core.protectHFS false && | |
57 | printf "100644 blob %s\t%s" "$blob" ".gi${u200c}t" >tree && | |
58 | ok=$(git mktree <tree) && | |
59 | git read-tree $ok | |
60 | ' | |
61 | ||
96b50cc1 | 62 | test_done |