Git 2.46-rc0
[git/gitster.git] / t / t7010-setup.sh
blobd9add2162e9c64d8fd5341cf83f123c7c57b7324
1 #!/bin/sh
3 test_description='setup taking and sanitizing funny paths'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success setup '
10 mkdir -p a/b/c a/e &&
11 D=$(pwd) &&
12 >a/b/c/d &&
13 >a/e/f
17 test_expect_success 'git add (absolute)' '
19 git add "$D/a/b/c/d" &&
20 git ls-files >current &&
21 echo a/b/c/d >expect &&
22 test_cmp expect current
27 test_expect_success 'git add (funny relative)' '
29 rm -f .git/index &&
31 cd a/b &&
32 git add "../e/./f"
33 ) &&
34 git ls-files >current &&
35 echo a/e/f >expect &&
36 test_cmp expect current
40 test_expect_success 'git rm (absolute)' '
42 rm -f .git/index &&
43 git add a &&
44 git rm -f --cached "$D/a/b/c/d" &&
45 git ls-files >current &&
46 echo a/e/f >expect &&
47 test_cmp expect current
51 test_expect_success 'git rm (funny relative)' '
53 rm -f .git/index &&
54 git add a &&
56 cd a/b &&
57 git rm -f --cached "../e/./f"
58 ) &&
59 git ls-files >current &&
60 echo a/b/c/d >expect &&
61 test_cmp expect current
65 test_expect_success 'git ls-files (absolute)' '
67 rm -f .git/index &&
68 git add a &&
69 git ls-files "$D/a/e/../b" >current &&
70 echo a/b/c/d >expect &&
71 test_cmp expect current
75 test_expect_success 'git ls-files (relative #1)' '
77 rm -f .git/index &&
78 git add a &&
80 cd a/b &&
81 git ls-files "../b/c"
82 ) >current &&
83 echo c/d >expect &&
84 test_cmp expect current
88 test_expect_success 'git ls-files (relative #2)' '
90 rm -f .git/index &&
91 git add a &&
93 cd a/b &&
94 git ls-files --full-name "../e/f"
95 ) >current &&
96 echo a/e/f >expect &&
97 test_cmp expect current
101 test_expect_success 'git ls-files (relative #3)' '
103 rm -f .git/index &&
104 git add a &&
106 cd a/b &&
107 git ls-files "../e/f"
108 ) >current &&
109 echo ../e/f >expect &&
110 test_cmp expect current
114 test_expect_success 'commit using absolute path names' '
115 git commit -m "foo" &&
116 echo aa >>a/b/c/d &&
117 git commit -m "aa" "$(pwd)/a/b/c/d"
120 test_expect_success 'log using absolute path names' '
121 echo bb >>a/b/c/d &&
122 git commit -m "bb" "$(pwd)/a/b/c/d" &&
124 git log a/b/c/d >f1.txt &&
125 git log "$(pwd)/a/b/c/d" >f2.txt &&
126 test_cmp f1.txt f2.txt
129 test_expect_success 'blame using absolute path names' '
130 git blame a/b/c/d >f1.txt &&
131 git blame "$(pwd)/a/b/c/d" >f2.txt &&
132 test_cmp f1.txt f2.txt
135 test_expect_success 'setup deeper work tree' '
136 test_create_repo tester
139 test_expect_success 'add a directory outside the work tree' '(
140 cd tester &&
141 d1="$(cd .. && pwd)" &&
142 test_must_fail git add "$d1"
146 test_expect_success 'add a file outside the work tree, nasty case 1' '(
147 cd tester &&
148 f="$(pwd)x" &&
149 echo "$f" &&
150 touch "$f" &&
151 test_must_fail git add "$f"
154 test_expect_success 'add a file outside the work tree, nasty case 2' '(
155 cd tester &&
156 f="$(pwd | sed "s/.$//")x" &&
157 echo "$f" &&
158 touch "$f" &&
159 test_must_fail git add "$f"
162 test_done