summaryrefslogtreecommitdiff
path: root/t/t7010-setup.sh
blob: d8a7c798525728ddc8fc5fa9bd8335d8d1f0a710 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/sh

test_description='setup taking and sanitizing funny paths'

. ./test-lib.sh

test_expect_success setup '

	mkdir -p a/b/c a/e &&
	D=$(pwd) &&
	>a/b/c/d &&
	>a/e/f

'

test_expect_success 'git add (absolute)' '

	git add "$D/a/b/c/d" &&
	git ls-files >current &&
	echo a/b/c/d >expect &&
	test_cmp expect current

'


test_expect_success 'git add (funny relative)' '

	rm -f .git/index &&
	(
		cd a/b &&
		git add "../e/./f"
	) &&
	git ls-files >current &&
	echo a/e/f >expect &&
	test_cmp expect current

'

test_expect_success 'git rm (absolute)' '

	rm -f .git/index &&
	git add a &&
	git rm -f --cached "$D/a/b/c/d" &&
	git ls-files >current &&
	echo a/e/f >expect &&
	test_cmp expect current

'

test_expect_success 'git rm (funny relative)' '

	rm -f .git/index &&
	git add a &&
	(
		cd a/b &&
		git rm -f --cached "../e/./f"
	) &&
	git ls-files >current &&
	echo a/b/c/d >expect &&
	test_cmp expect current

'

test_expect_success 'git ls-files (absolute)' '

	rm -f .git/index &&
	git add a &&
	git ls-files "$D/a/e/../b" >current &&
	echo a/b/c/d >expect &&
	test_cmp expect current

'

test_expect_success 'git ls-files (relative #1)' '

	rm -f .git/index &&
	git add a &&
	(
		cd a/b &&
		git ls-files "../b/c"
	)  >current &&
	echo c/d >expect &&
	test_cmp expect current

'

test_expect_success 'git ls-files (relative #2)' '

	rm -f .git/index &&
	git add a &&
	(
		cd a/b &&
		git ls-files --full-name "../e/f"
	)  >current &&
	echo a/e/f >expect &&
	test_cmp expect current

'

test_expect_success 'git ls-files (relative #3)' '

	rm -f .git/index &&
	git add a &&
	(
		cd a/b &&
		if git ls-files "../e/f"
		then
			echo Gaah, should have failed
			exit 1
		else
			: happy
		fi
	)

'

test_expect_success 'commit using absolute path names' '
	git commit -m "foo" &&
	echo aa >>a/b/c/d &&
	git commit -m "aa" "$(pwd)/a/b/c/d"
'

test_expect_success 'log using absolute path names' '
	echo bb >>a/b/c/d &&
	git commit -m "bb" "$(pwd)/a/b/c/d" &&

	git log a/b/c/d >f1.txt &&
	git log "$(pwd)/a/b/c/d" >f2.txt &&
	test_cmp f1.txt f2.txt
'

test_expect_success 'blame using absolute path names' '
	git blame a/b/c/d >f1.txt &&
	git blame "$(pwd)/a/b/c/d" >f2.txt &&
	test_cmp f1.txt f2.txt
'

test_expect_success 'setup deeper work tree' '
	test_create_repo tester
'

test_expect_success 'add a directory outside the work tree' '(
	cd tester &&
	d1="$(cd .. ; pwd)" &&
	test_must_fail git add "$d1"
)'


test_expect_success 'add a file outside the work tree, nasty case 1' '(
	cd tester &&
	f="$(pwd)x" &&
	echo "$f" &&
	touch "$f" &&
	test_must_fail git add "$f"
)'

test_expect_success 'add a file outside the work tree, nasty case 2' '(
	cd tester &&
	f="$(pwd | sed "s/.$//")x" &&
	echo "$f" &&
	touch "$f" &&
	test_must_fail git add "$f"
)'

test_done