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