]> git.ipfire.org Git - thirdparty/git.git/blame - t/t7010-setup.sh
add test_cmp function for test scripts
[thirdparty/git.git] / t / t7010-setup.sh
CommitLineData
d089ebaa
JH
1#!/bin/sh
2
3test_description='setup taking and sanitizing funny paths'
4
5. ./test-lib.sh
6
7test_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
16test_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 &&
82ebb0b6 21 test_cmp expect current
d089ebaa
JH
22
23'
24
25
26test_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 &&
82ebb0b6 35 test_cmp expect current
d089ebaa
JH
36
37'
38
39test_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 &&
82ebb0b6 46 test_cmp expect current
d089ebaa
JH
47
48'
49
50test_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 &&
82ebb0b6 60 test_cmp expect current
d089ebaa
JH
61
62'
63
64test_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 &&
82ebb0b6 70 test_cmp expect current
d089ebaa
JH
71
72'
73
74test_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 &&
82ebb0b6 83 test_cmp expect current
d089ebaa
JH
84
85'
86
87test_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 &&
82ebb0b6 96 test_cmp expect current
d089ebaa
JH
97
98'
99
100test_expect_success 'git ls-files (relative #3)' '
101
102 rm -f .git/index &&
103 git add a &&
104 (
105 cd a/b &&
106 if git ls-files "../e/f"
107 then
108 echo Gaah, should have failed
109 exit 1
110 else
111 : happy
112 fi
113 )
114
115'
116
1abf0950
JH
117test_expect_success 'commit using absolute path names' '
118 git commit -m "foo" &&
119 echo aa >>a/b/c/d &&
120 git commit -m "aa" "$(pwd)/a/b/c/d"
121'
122
123test_expect_success 'log using absolute path names' '
124 echo bb >>a/b/c/d &&
125 git commit -m "bb" $(pwd)/a/b/c/d &&
126
127 git log a/b/c/d >f1.txt &&
128 git log "$(pwd)/a/b/c/d" >f2.txt &&
82ebb0b6 129 test_cmp f1.txt f2.txt
1abf0950
JH
130'
131
132test_expect_success 'blame using absolute path names' '
133 git blame a/b/c/d >f1.txt &&
134 git blame "$(pwd)/a/b/c/d" >f2.txt &&
82ebb0b6 135 test_cmp f1.txt f2.txt
1abf0950
JH
136'
137
138test_expect_success 'setup deeper work tree' '
139 test_create_repo tester
140'
141
142test_expect_success 'add a directory outside the work tree' '(
143 cd tester &&
144 d1="$(cd .. ; pwd)" &&
3296766e 145 test_must_fail git add "$d1"
1abf0950
JH
146)'
147
3296766e 148
1abf0950
JH
149test_expect_success 'add a file outside the work tree, nasty case 1' '(
150 cd tester &&
151 f="$(pwd)x" &&
152 echo "$f" &&
153 touch "$f" &&
3296766e 154 test_must_fail git add "$f"
1abf0950
JH
155)'
156
157test_expect_success 'add a file outside the work tree, nasty case 2' '(
158 cd tester &&
159 f="$(pwd | sed "s/.$//")x" &&
160 echo "$f" &&
161 touch "$f" &&
3296766e 162 test_must_fail git add "$f"
1abf0950
JH
163)'
164
d089ebaa 165test_done