summaryrefslogtreecommitdiff
path: root/t/t9168-git-svn-partially-globbed-names.sh
blob: 854b3419b2c3239090750f96dde3608d25c90136 (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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#!/bin/sh
test_description='git svn globbing refspecs with prefixed globs'
. ./lib-git-svn.sh

test_expect_success 'prepare test refspec prefixed globbing' '
	cat >expect.end <<EOF
the end
hi
start a new branch
initial
EOF
	'

test_expect_success 'test refspec prefixed globbing' '
	mkdir -p trunk/src/a trunk/src/b trunk/doc &&
	echo "hello world" >trunk/src/a/readme &&
	echo "goodbye world" >trunk/src/b/readme &&
	svn_cmd import -m "initial" trunk "$svnrepo"/trunk &&
	svn_cmd co "$svnrepo" tmp &&
	(
		cd tmp &&
		mkdir branches tags &&
		svn_cmd add branches tags &&
		svn_cmd cp trunk branches/b_start &&
		svn_cmd commit -m "start a new branch" &&
		svn_cmd up &&
		echo "hi" >>branches/b_start/src/b/readme &&
		poke branches/b_start/src/b/readme &&
		echo "hey" >>branches/b_start/src/a/readme &&
		poke branches/b_start/src/a/readme &&
		svn_cmd commit -m "hi" &&
		svn_cmd up &&
		svn_cmd cp branches/b_start tags/t_end &&
		echo "bye" >>tags/t_end/src/b/readme &&
		poke tags/t_end/src/b/readme &&
		echo "aye" >>tags/t_end/src/a/readme &&
		poke tags/t_end/src/a/readme &&
		svn_cmd commit -m "the end" &&
		echo "byebye" >>tags/t_end/src/b/readme &&
		poke tags/t_end/src/b/readme &&
		svn_cmd commit -m "nothing to see here"
	) &&
	git config --add svn-remote.svn.url "$svnrepo" &&
	git config --add svn-remote.svn.fetch \
			 "trunk/src/a:refs/remotes/trunk" &&
	git config --add svn-remote.svn.branches \
			 "branches/b_*/src/a:refs/remotes/branches/b_*" &&
	git config --add svn-remote.svn.tags\
			 "tags/t_*/src/a:refs/remotes/tags/t_*" &&
	git svn multi-fetch &&
	git log --pretty=oneline refs/remotes/tags/t_end >actual &&
	cut -d" " -f2- actual >output.end &&
	test_cmp expect.end output.end &&
	test "$(git rev-parse refs/remotes/tags/t_end~1)" = \
		"$(git rev-parse refs/remotes/branches/b_start)" &&
	test "$(git rev-parse refs/remotes/branches/b_start~2)" = \
		"$(git rev-parse refs/remotes/trunk)" &&
	test_must_fail git rev-parse refs/remotes/tags/t_end@3
	'

test_expect_success 'prepare test left-hand-side only prefixed globbing' '
	echo try to try >expect.two &&
	echo nothing to see here >>expect.two &&
	cat expect.end >>expect.two
	'

test_expect_success 'test left-hand-side only prefixed globbing' '
	git config --add svn-remote.two.url "$svnrepo" &&
	git config --add svn-remote.two.fetch trunk:refs/remotes/two/trunk &&
	git config --add svn-remote.two.branches \
			 "branches/b_*:refs/remotes/two/branches/*" &&
	git config --add svn-remote.two.tags \
			 "tags/t_*:refs/remotes/two/tags/*" &&
	(
		cd tmp &&
		echo "try try" >>tags/t_end/src/b/readme &&
		poke tags/t_end/src/b/readme &&
		svn_cmd commit -m "try to try"
	) &&
	git svn fetch two &&
	git rev-list refs/remotes/two/tags/t_end >actual &&
	test_line_count = 6 actual &&
	git rev-list refs/remotes/two/branches/b_start >actual &&
	test_line_count = 3 actual &&
	test $(git rev-parse refs/remotes/two/branches/b_start~2) = \
	     $(git rev-parse refs/remotes/two/trunk) &&
	test $(git rev-parse refs/remotes/two/tags/t_end~3) = \
	     $(git rev-parse refs/remotes/two/branches/b_start) &&
	git log --pretty=oneline refs/remotes/two/tags/t_end >actual &&
	cut -d" " -f2- actual >output.two &&
	test_cmp expect.two output.two
	'

test_expect_success 'prepare test prefixed globs match just prefix' '
	cat >expect.three <<EOF
Tag commit to t_
Branch commit to b_
initial
EOF
	'

test_expect_success 'test prefixed globs match just prefix' '
	git config --add svn-remote.three.url "$svnrepo" &&
	git config --add svn-remote.three.fetch \
			 trunk:refs/remotes/three/trunk &&
	git config --add svn-remote.three.branches \
			 "branches/b_*:refs/remotes/three/branches/*" &&
	git config --add svn-remote.three.tags \
			 "tags/t_*:refs/remotes/three/tags/*" &&
	(
		cd tmp &&
		svn_cmd cp trunk branches/b_ &&
		echo "Branch commit to b_" >>branches/b_/src/a/readme &&
		poke branches/b_/src/a/readme &&
		svn_cmd commit -m "Branch commit to b_" &&
		svn_cmd up && svn_cmd cp branches/b_ tags/t_ &&
		echo "Tag commit to t_" >>tags/t_/src/a/readme &&
		poke tags/t_/src/a/readme &&
		svn_cmd commit -m "Tag commit to t_" &&
		svn_cmd up
	) &&
	git svn fetch three &&
	git rev-list refs/remotes/three/branches/b_ >actual &&
	test_line_count = 2 actual &&
	git rev-list refs/remotes/three/tags/t_ >actual &&
	test_line_count = 3 actual &&
	test $(git rev-parse refs/remotes/three/branches/b_~1) = \
	     $(git rev-parse refs/remotes/three/trunk) &&
	test $(git rev-parse refs/remotes/three/tags/t_~1) = \
	     $(git rev-parse refs/remotes/three/branches/b_) &&
	git log --pretty=oneline refs/remotes/three/tags/t_ >actual &&
	cut -d" " -f2- actual >output.three &&
	test_cmp expect.three output.three
	'

test_expect_success 'prepare test disallow prefixed multi-globs' "
cat >expect.four <<EOF
Only one set of wildcards (e.g. '*' or '*/*/*') is supported: branches/b_*/t/*

EOF
	"

test_expect_success 'test disallow prefixed multi-globs' '
	git config --add svn-remote.four.url "$svnrepo" &&
	git config --add svn-remote.four.fetch \
			 trunk:refs/remotes/four/trunk &&
	git config --add svn-remote.four.branches \
			 "branches/b_*/t/*:refs/remotes/four/branches/*" &&
	git config --add svn-remote.four.tags \
			 "tags/t_*/*:refs/remotes/four/tags/*" &&
	(
		cd tmp &&
		echo "try try" >>tags/t_end/src/b/readme &&
		poke tags/t_end/src/b/readme &&
		svn_cmd commit -m "try to try"
	) &&
	test_must_fail git svn fetch four 2>stderr.four &&
	test_cmp expect.four stderr.four &&
	git config --unset svn-remote.four.branches &&
	git config --unset svn-remote.four.tags
	'

test_expect_success 'prepare test globbing in the middle of the word' '
	cat >expect.five <<EOF
Tag commit to fghij
Branch commit to abcde
initial
EOF
	'

test_expect_success 'test globbing in the middle of the word' '
	git config --add svn-remote.five.url "$svnrepo" &&
	git config --add svn-remote.five.fetch \
			 trunk:refs/remotes/five/trunk &&
	git config --add svn-remote.five.branches \
			 "branches/a*e:refs/remotes/five/branches/*" &&
	git config --add svn-remote.five.tags \
			 "tags/f*j:refs/remotes/five/tags/*" &&
	(
		cd tmp &&
		svn_cmd cp trunk branches/abcde &&
		echo "Branch commit to abcde" >>branches/abcde/src/a/readme &&
		poke branches/b_/src/a/readme &&
		svn_cmd commit -m "Branch commit to abcde" &&
		svn_cmd up &&
		svn_cmd cp branches/abcde tags/fghij &&
		echo "Tag commit to fghij" >>tags/fghij/src/a/readme &&
		poke tags/fghij/src/a/readme &&
		svn_cmd commit -m "Tag commit to fghij" &&
		svn_cmd up
	) &&
	git svn fetch five &&
	git rev-list refs/remotes/five/branches/abcde >actual &&
	test_line_count = 2 actual &&
	git rev-list refs/remotes/five/tags/fghij >actual &&
	test_line_count = 3 actual &&
	test $(git rev-parse refs/remotes/five/branches/abcde~1) = \
	     $(git rev-parse refs/remotes/five/trunk) &&
	test $(git rev-parse refs/remotes/five/tags/fghij~1) = \
	     $(git rev-parse refs/remotes/five/branches/abcde) &&
	git log --pretty=oneline refs/remotes/five/tags/fghij >actual &&
	cut -d" " -f2- actual >output.five &&
	test_cmp expect.five output.five
	'

test_expect_success 'prepare test disallow multiple asterisks in one word' "
	echo \"Only one '*' is allowed in a pattern: 'a*c*e'\" >expect.six &&
	echo \"\" >>expect.six
	"

test_expect_success 'test disallow multiple asterisks in one word' '
	git config --add svn-remote.six.url "$svnrepo" &&
	git config --add svn-remote.six.fetch \
			 trunk:refs/remotes/six/trunk &&
	git config --add svn-remote.six.branches \
			 "branches/a*c*e:refs/remotes/six/branches/*" &&
	git config --add svn-remote.six.tags \
			 "tags/f*h*j:refs/remotes/six/tags/*" &&
	(
		cd tmp &&
		echo "try try" >>tags/fghij/src/b/readme &&
		poke tags/fghij/src/b/readme &&
		svn_cmd commit -m "try to try"
	) &&
	test_must_fail git svn fetch six 2>stderr.six &&
	test_cmp expect.six stderr.six
	'

test_done