Junio C Hamano | d089eba | 2008-01-28 22:44:27 -0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='setup taking and sanitizing funny paths' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success setup ' |
| 8 | |
| 9 | mkdir -p a/b/c a/e && |
| 10 | D=$(pwd) && |
| 11 | >a/b/c/d && |
| 12 | >a/e/f |
| 13 | |
| 14 | ' |
| 15 | |
| 16 | test_expect_success 'git add (absolute)' ' |
| 17 | |
| 18 | git add "$D/a/b/c/d" && |
| 19 | git ls-files >current && |
| 20 | echo a/b/c/d >expect && |
Jeff King | 82ebb0b | 2008-03-12 17:36:36 -0400 | [diff] [blame] | 21 | test_cmp expect current |
Junio C Hamano | d089eba | 2008-01-28 22:44:27 -0800 | [diff] [blame] | 22 | |
| 23 | ' |
| 24 | |
| 25 | |
| 26 | test_expect_success 'git add (funny relative)' ' |
| 27 | |
| 28 | rm -f .git/index && |
| 29 | ( |
| 30 | cd a/b && |
| 31 | git add "../e/./f" |
| 32 | ) && |
| 33 | git ls-files >current && |
| 34 | echo a/e/f >expect && |
Jeff King | 82ebb0b | 2008-03-12 17:36:36 -0400 | [diff] [blame] | 35 | test_cmp expect current |
Junio C Hamano | d089eba | 2008-01-28 22:44:27 -0800 | [diff] [blame] | 36 | |
| 37 | ' |
| 38 | |
| 39 | test_expect_success 'git rm (absolute)' ' |
| 40 | |
| 41 | rm -f .git/index && |
| 42 | git add a && |
| 43 | git rm -f --cached "$D/a/b/c/d" && |
| 44 | git ls-files >current && |
| 45 | echo a/e/f >expect && |
Jeff King | 82ebb0b | 2008-03-12 17:36:36 -0400 | [diff] [blame] | 46 | test_cmp expect current |
Junio C Hamano | d089eba | 2008-01-28 22:44:27 -0800 | [diff] [blame] | 47 | |
| 48 | ' |
| 49 | |
| 50 | test_expect_success 'git rm (funny relative)' ' |
| 51 | |
| 52 | rm -f .git/index && |
| 53 | git add a && |
| 54 | ( |
| 55 | cd a/b && |
| 56 | git rm -f --cached "../e/./f" |
| 57 | ) && |
| 58 | git ls-files >current && |
| 59 | echo a/b/c/d >expect && |
Jeff King | 82ebb0b | 2008-03-12 17:36:36 -0400 | [diff] [blame] | 60 | test_cmp expect current |
Junio C Hamano | d089eba | 2008-01-28 22:44:27 -0800 | [diff] [blame] | 61 | |
| 62 | ' |
| 63 | |
| 64 | test_expect_success 'git ls-files (absolute)' ' |
| 65 | |
| 66 | rm -f .git/index && |
| 67 | git add a && |
| 68 | git ls-files "$D/a/e/../b" >current && |
| 69 | echo a/b/c/d >expect && |
Jeff King | 82ebb0b | 2008-03-12 17:36:36 -0400 | [diff] [blame] | 70 | test_cmp expect current |
Junio C Hamano | d089eba | 2008-01-28 22:44:27 -0800 | [diff] [blame] | 71 | |
| 72 | ' |
| 73 | |
| 74 | test_expect_success 'git ls-files (relative #1)' ' |
| 75 | |
| 76 | rm -f .git/index && |
| 77 | git add a && |
| 78 | ( |
| 79 | cd a/b && |
| 80 | git ls-files "../b/c" |
| 81 | ) >current && |
| 82 | echo c/d >expect && |
Jeff King | 82ebb0b | 2008-03-12 17:36:36 -0400 | [diff] [blame] | 83 | test_cmp expect current |
Junio C Hamano | d089eba | 2008-01-28 22:44:27 -0800 | [diff] [blame] | 84 | |
| 85 | ' |
| 86 | |
| 87 | test_expect_success 'git ls-files (relative #2)' ' |
| 88 | |
| 89 | rm -f .git/index && |
| 90 | git add a && |
| 91 | ( |
| 92 | cd a/b && |
| 93 | git ls-files --full-name "../e/f" |
| 94 | ) >current && |
| 95 | echo a/e/f >expect && |
Jeff King | 82ebb0b | 2008-03-12 17:36:36 -0400 | [diff] [blame] | 96 | test_cmp expect current |
Junio C Hamano | d089eba | 2008-01-28 22:44:27 -0800 | [diff] [blame] | 97 | |
| 98 | ' |
| 99 | |
| 100 | test_expect_success 'git ls-files (relative #3)' ' |
| 101 | |
| 102 | rm -f .git/index && |
| 103 | git add a && |
| 104 | ( |
| 105 | cd a/b && |
Clemens Buchacher | efad1a5 | 2010-06-03 15:39:18 +0200 | [diff] [blame] | 106 | git ls-files "../e/f" |
| 107 | ) >current && |
| 108 | echo ../e/f >expect && |
| 109 | test_cmp expect current |
Junio C Hamano | d089eba | 2008-01-28 22:44:27 -0800 | [diff] [blame] | 110 | |
| 111 | ' |
| 112 | |
Junio C Hamano | 1abf095 | 2008-02-01 03:13:10 -0800 | [diff] [blame] | 113 | test_expect_success 'commit using absolute path names' ' |
| 114 | git commit -m "foo" && |
| 115 | echo aa >>a/b/c/d && |
| 116 | git commit -m "aa" "$(pwd)/a/b/c/d" |
| 117 | ' |
| 118 | |
| 119 | test_expect_success 'log using absolute path names' ' |
| 120 | echo bb >>a/b/c/d && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 121 | git commit -m "bb" "$(pwd)/a/b/c/d" && |
Junio C Hamano | 1abf095 | 2008-02-01 03:13:10 -0800 | [diff] [blame] | 122 | |
| 123 | git log a/b/c/d >f1.txt && |
| 124 | git log "$(pwd)/a/b/c/d" >f2.txt && |
Jeff King | 82ebb0b | 2008-03-12 17:36:36 -0400 | [diff] [blame] | 125 | test_cmp f1.txt f2.txt |
Junio C Hamano | 1abf095 | 2008-02-01 03:13:10 -0800 | [diff] [blame] | 126 | ' |
| 127 | |
| 128 | test_expect_success 'blame using absolute path names' ' |
| 129 | git blame a/b/c/d >f1.txt && |
| 130 | git blame "$(pwd)/a/b/c/d" >f2.txt && |
Jeff King | 82ebb0b | 2008-03-12 17:36:36 -0400 | [diff] [blame] | 131 | test_cmp f1.txt f2.txt |
Junio C Hamano | 1abf095 | 2008-02-01 03:13:10 -0800 | [diff] [blame] | 132 | ' |
| 133 | |
| 134 | test_expect_success 'setup deeper work tree' ' |
| 135 | test_create_repo tester |
| 136 | ' |
| 137 | |
| 138 | test_expect_success 'add a directory outside the work tree' '( |
| 139 | cd tester && |
| 140 | d1="$(cd .. ; pwd)" && |
Junio C Hamano | 3296766 | 2008-03-06 23:18:08 -0800 | [diff] [blame] | 141 | test_must_fail git add "$d1" |
Junio C Hamano | 1abf095 | 2008-02-01 03:13:10 -0800 | [diff] [blame] | 142 | )' |
| 143 | |
Junio C Hamano | 3296766 | 2008-03-06 23:18:08 -0800 | [diff] [blame] | 144 | |
Junio C Hamano | 1abf095 | 2008-02-01 03:13:10 -0800 | [diff] [blame] | 145 | test_expect_success 'add a file outside the work tree, nasty case 1' '( |
| 146 | cd tester && |
| 147 | f="$(pwd)x" && |
| 148 | echo "$f" && |
| 149 | touch "$f" && |
Junio C Hamano | 3296766 | 2008-03-06 23:18:08 -0800 | [diff] [blame] | 150 | test_must_fail git add "$f" |
Junio C Hamano | 1abf095 | 2008-02-01 03:13:10 -0800 | [diff] [blame] | 151 | )' |
| 152 | |
| 153 | test_expect_success 'add a file outside the work tree, nasty case 2' '( |
| 154 | cd tester && |
| 155 | f="$(pwd | sed "s/.$//")x" && |
| 156 | echo "$f" && |
| 157 | touch "$f" && |
Junio C Hamano | 3296766 | 2008-03-06 23:18:08 -0800 | [diff] [blame] | 158 | test_must_fail git add "$f" |
Junio C Hamano | 1abf095 | 2008-02-01 03:13:10 -0800 | [diff] [blame] | 159 | )' |
| 160 | |
Junio C Hamano | d089eba | 2008-01-28 22:44:27 -0800 | [diff] [blame] | 161 | test_done |