blob: 2f5a25d503861a5a03e60bdc1087f27f72c0e60e [file] [log] [blame]
Jeff King96b50cc2014-11-24 13:37:56 -05001#!/bin/sh
2
3test_description='check that read-tree rejects confusing paths'
4. ./test-lib.sh
5
6test_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
Jeff Kinga42643a2014-12-15 18:15:20 -050014test_expect_success 'enable core.protectHFS for rejection tests' '
15 git config core.protectHFS true
16'
17
Johannes Schindelin2b4c6ef2014-12-16 23:46:59 +010018test_expect_success 'enable core.protectNTFS for rejection tests' '
19 git config core.protectNTFS true
20'
21
Jeff Kinga42643a2014-12-15 18:15:20 -050022while read path pretty; do
23 : ${pretty:=$path}
Johannes Schindelin2b4c6ef2014-12-16 23:46:59 +010024 case "$path" in
25 *SPACE)
26 path="${path%SPACE} "
27 ;;
28 esac
Jeff Kinga42643a2014-12-15 18:15:20 -050029 test_expect_success "reject $pretty at end of path" '
Jeff King96b50cc2014-11-24 13:37:56 -050030 printf "100644 blob %s\t%s" "$blob" "$path" >tree &&
31 bogus=$(git mktree <tree) &&
32 test_must_fail git read-tree $bogus
33 '
34
Jeff Kinga42643a2014-12-15 18:15:20 -050035 test_expect_success "reject $pretty as subtree" '
Jeff King96b50cc2014-11-24 13:37:56 -050036 printf "040000 tree %s\t%s" "$tree" "$path" >tree &&
37 bogus=$(git mktree <tree) &&
38 test_must_fail git read-tree $bogus
39 '
Jeff Kinga42643a2014-12-15 18:15:20 -050040done <<-EOF
Jeff King96b50cc2014-11-24 13:37:56 -050041.
42..
43.git
Jeff Kingcc2fc7c2014-11-24 13:39:12 -050044.GIT
Jeff Kinga42643a2014-12-15 18:15:20 -050045${u200c}.Git {u200c}.Git
46.gI${u200c}T .gI{u200c}T
47.GiT${u200c} .GiT{u200c}
Johannes Schindelin2b4c6ef2014-12-16 23:46:59 +010048git~1
49.git.SPACE .git.{space}
50.\\\\.GIT\\\\foobar backslashes
51.git\\\\foobar backslashes2
Jeff King96b50cc2014-11-24 13:37:56 -050052EOF
53
Jeff Kinga42643a2014-12-15 18:15:20 -050054test_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
Jeff King96b50cc2014-11-24 13:37:56 -050062test_done