3 test_description
='tg import tests'
11 test_expect_success
'default branch import' '
12 test_create_repo r1 && cd r1 &&
13 test_commit --notick start^here &&
15 test_commit --notick one^ &&
16 test_commit --notick two^ &&
17 test_commit --notick three^ &&
19 tg import base..master &&
22 t/three [PATCH] three^
25 tg summary -v -l | tr -s "\\t" " " > ../actual &&
26 test_diff ../expected ../actual &&
33 tg summary --rdeps --heads > ../actual &&
34 test_diff ../expected ../actual &&
35 test_cmp_rev base "$(tg base t/one)" &&
36 git diff --exit-code master t/three -- :/ :\!/.topdeps :\!/.topmsg
39 test_expect_success
'specified branch import' '
40 test_create_repo r2 && cd r2 &&
41 test_commit --notick start^here &&
43 test_commit --notick one^ &&
44 test_commit --notick two^ &&
45 test_commit --notick three^ &&
46 git checkout --orphan alt &&
47 git read-tree --empty &&
48 git commit --allow-empty -m "empty" &&
51 tg import -d alt base..master &&
54 t/three [PATCH] three^
57 tg summary -v -l | tr -s "\\t" " " > ../actual &&
58 test_diff ../expected ../actual &&
65 tg summary --rdeps --heads > ../actual &&
66 test_diff ../expected ../actual &&
67 test_cmp_rev alt "$(tg base t/one)" &&
69 diff --git a/start^here.t b/start^here.t
70 deleted file mode 100644
71 index 1a2b97e..0000000
77 git diff master t/three -- :/ :\!/.topdeps :\!/.topmsg > ../actual &&
78 test_diff ../expected ../actual
81 test_expect_success
'specified branch import HEAD relative range' '
82 test_create_repo r3 && cd r3 &&
83 test_commit --notick start^here &&
85 test_commit --notick one^ &&
86 test_commit --notick two^ &&
87 test_commit --notick three^ &&
88 git checkout --orphan alt &&
89 git read-tree --empty &&
90 git commit --allow-empty -m "empty" &&
92 git checkout master &&
93 tg import -d alt HEAD~3..HEAD &&
96 t/three [PATCH] three^
99 tg summary -v -l | tr -s "\\t" " " > ../actual &&
100 test_diff ../expected ../actual &&
107 tg summary --rdeps --heads > ../actual &&
108 test_diff ../expected ../actual &&
109 test_cmp_rev alt "$(tg base t/one)" &&
111 diff --git a/start^here.t b/start^here.t
112 deleted file mode 100644
113 index 1a2b97e..0000000
119 git diff master t/three -- :/ :\!/.topdeps :\!/.topmsg > ../actual &&
120 test_diff ../expected ../actual
122 test_expect_success
'specified branch import foo..HEAD implied relative range' '
123 test_create_repo r4 && cd r4 &&
124 test_commit --notick start^here &&
126 test_commit --notick one^ &&
127 test_commit --notick two^ &&
128 test_commit --notick three^ &&
129 git checkout --orphan alt &&
130 git read-tree --empty &&
131 git commit --allow-empty -m "empty" &&
132 git clean -d -f -x &&
133 git checkout master &&
134 tg import -d alt HEAD~3.. &&
137 t/three [PATCH] three^
140 tg summary -v -l | tr -s "\\t" " " > ../actual &&
141 test_diff ../expected ../actual &&
148 tg summary --rdeps --heads > ../actual &&
149 test_diff ../expected ../actual &&
150 test_cmp_rev alt "$(tg base t/one)" &&
152 diff --git a/start^here.t b/start^here.t
153 deleted file mode 100644
154 index 1a2b97e..0000000
160 git diff master t/three -- :/ :\!/.topdeps :\!/.topmsg > ../actual &&
161 test_diff ../expected ../actual
164 test_expect_success
'specified branch import HEAD..foo implied relative range' '
165 test_create_repo r5 && cd r5 &&
166 test_commit --notick start^here &&
168 test_commit --notick one^ &&
169 test_commit --notick two^ &&
170 test_commit --notick three^ &&
171 git checkout --orphan alt &&
172 git read-tree --empty &&
173 git commit --allow-empty -m "empty" &&
174 git clean -d -f -x &&
176 tg import -d alt ..master &&
179 t/three [PATCH] three^
182 tg summary -v -l | tr -s "\\t" " " > ../actual &&
183 test_diff ../expected ../actual &&
190 tg summary --rdeps --heads > ../actual &&
191 test_diff ../expected ../actual &&
192 test_cmp_rev alt "$(tg base t/one)" &&
194 diff --git a/start^here.t b/start^here.t
195 deleted file mode 100644
196 index 1a2b97e..0000000
202 git diff master t/three -- :/ :\!/.topdeps :\!/.topmsg > ../actual &&
203 test_diff ../expected ../actual
206 test_expect_success
'specified branch import HEAD relative single commit range' '
207 test_create_repo r6 && cd r6 &&
208 test_commit --notick start^here &&
210 test_commit --notick one^ &&
211 test_commit --notick two^ &&
213 test_commit --notick three^ &&
214 git checkout --orphan alt &&
215 git read-tree --empty &&
216 git commit --allow-empty -m "empty" &&
217 git clean -d -f -x &&
218 git checkout master &&
219 tg import -d alt HEAD~^\! &&
223 tg summary -v -l | tr -s "\\t" " " > ../actual &&
224 test_diff ../expected ../actual &&
229 tg summary --rdeps --heads > ../actual &&
230 test_diff ../expected ../actual &&
231 test_cmp_rev alt "$(tg base t/two)" &&
233 diff --git a/one^.t b/one^.t
234 deleted file mode 100644
235 index 9a60eae..0000000
240 diff --git a/start^here.t b/start^here.t
241 deleted file mode 100644
242 index 1a2b97e..0000000
248 git diff "test#2" t/two -- :/ :\!/.topdeps :\!/.topmsg > ../actual &&
249 test_diff ../expected ../actual
252 test_expect_success
'default unrelated branch import' '
253 test_create_repo r7 && cd r7 &&
254 test_commit --notick start^here &&
256 test_commit --notick one^ &&
257 test_commit --notick two^ &&
258 test_commit --notick three^ &&
259 git checkout --orphan alt &&
260 git read-tree --empty &&
261 git commit --allow-empty -m "empty" &&
262 git clean -d -f -x &&
263 tg import base..master &&
266 t/three [PATCH] three^
269 tg summary -v -l | tr -s "\\t" " " > ../actual &&
270 test_diff ../expected ../actual &&
277 tg summary --rdeps --heads > ../actual &&
278 test_diff ../expected ../actual &&
279 test_cmp_rev alt "$(tg base t/one)" &&
281 diff --git a/start^here.t b/start^here.t
282 deleted file mode 100644
283 index 1a2b97e..0000000
289 git diff master t/three -- :/ :\!/.topdeps :\!/.topmsg > ../actual &&
290 test_diff ../expected ../actual
293 test_expect_success
'HEAD unrelated branch import' '
294 test_create_repo r8 && cd r8 &&
295 test_commit --notick start^here &&
297 test_commit --notick one^ &&
298 test_commit --notick two^ &&
299 test_commit --notick three^ &&
300 git checkout --orphan alt &&
301 git read-tree --empty &&
302 git commit --allow-empty -m "empty" &&
303 git clean -d -f -x &&
304 tg import -d HEAD base..master &&
307 t/three [PATCH] three^
310 tg summary -v -l | tr -s "\\t" " " > ../actual &&
311 test_diff ../expected ../actual &&
318 tg summary --rdeps --heads > ../actual &&
319 test_diff ../expected ../actual &&
320 test_cmp_rev alt "$(tg base t/one)" &&
322 diff --git a/start^here.t b/start^here.t
323 deleted file mode 100644
324 index 1a2b97e..0000000
330 git diff master t/three -- :/ :\!/.topdeps :\!/.topmsg > ../actual &&
331 test_diff ../expected ../actual
334 test_expect_success
'@ unrelated branch import' '
335 test_create_repo r9 && cd r9 &&
336 test_commit --notick start^here &&
338 test_commit --notick one^ &&
339 test_commit --notick two^ &&
340 test_commit --notick three^ &&
341 git checkout --orphan alt &&
342 git read-tree --empty &&
343 git commit --allow-empty -m "empty" &&
344 git clean -d -f -x &&
345 tg import -d HEAD base..master &&
348 t/three [PATCH] three^
351 tg summary -v -l | tr -s "\\t" " " > ../actual &&
352 test_diff ../expected ../actual &&
359 tg summary --rdeps --heads > ../actual &&
360 test_diff ../expected ../actual &&
361 test_cmp_rev alt "$(tg base t/one)" &&
363 diff --git a/start^here.t b/start^here.t
364 deleted file mode 100644
365 index 1a2b97e..0000000
371 git diff master t/three -- :/ :\!/.topdeps :\!/.topmsg > ../actual &&
372 test_diff ../expected ../actual
375 test_expect_success
'detached HEAD import fails' '
376 test_create_repo r10 && cd r10 &&
377 test_commit --notick start^here &&
379 test_commit --notick one^ &&
380 test_commit --notick two^ &&
381 test_commit --notick three^ &&
382 git checkout --orphan alt &&
383 git read-tree --empty &&
384 git commit --allow-empty -m "empty" &&
385 git clean -d -f -x &&
386 git checkout --detach HEAD &&
387 test_must_fail tg import base..master &&
388 test_must_fail tg import -d HEAD base..master &&
389 test_must_fail tg import -d @ base..master
393 ! vcmp
"$git_version" '>=' "2.9" || auh_opt
="--allow-unrelated-histories"
395 test_expect_success
'single commit range requires exactly one parent' '
396 test_create_repo r11 && cd r11 &&
397 test_commit --notick start^here &&
399 git checkout --orphan alt &&
400 git read-tree --empty &&
401 git commit --allow-empty -m empty &&
402 git clean -d -f -x &&
403 git checkout master &&
404 git merge $auh_opt -m merged alt &&
405 test_must_fail tg import HEAD^\! &&
406 test_must_fail tg import base^\!