3 test_description
='tg import tests'
11 case "$test_hash_algo" in
22 test_expect_success
'default branch import' '
23 test_create_repo r1 && cd r1 &&
24 test_commit --notick start^here &&
26 test_commit --notick one^ &&
27 test_commit --notick two^ &&
28 test_commit --notick three^ &&
30 tg import base..master &&
33 t/three [PATCH] three^
36 tg summary -v -l | tr -s "\\t" " " > ../actual &&
37 test_diff ../expected ../actual &&
44 tg summary --rdeps --heads > ../actual &&
45 test_diff ../expected ../actual &&
46 test_cmp_rev base "$(tg base t/one)" &&
47 git diff --exit-code master t/three -- :/ :\!/.topdeps :\!/.topmsg
50 test_expect_success
'specified branch import' '
51 test_create_repo r2 && cd r2 &&
52 test_commit --notick start^here &&
54 test_commit --notick one^ &&
55 test_commit --notick two^ &&
56 test_commit --notick three^ &&
57 git checkout --orphan alt &&
58 git read-tree --empty &&
59 git commit --allow-empty -m "empty" &&
62 tg import -d alt base..master &&
65 t/three [PATCH] three^
68 tg summary -v -l | tr -s "\\t" " " > ../actual &&
69 test_diff ../expected ../actual &&
76 tg summary --rdeps --heads > ../actual &&
77 test_diff ../expected ../actual &&
78 test_cmp_rev alt "$(tg base t/one)" &&
80 diff --git a/start^here.t b/start^here.t
81 deleted file mode 100644
82 index $startblob..0000000
88 git diff master t/three -- :/ :\!/.topdeps :\!/.topmsg > ../actual &&
89 test_diff ../expected ../actual
92 test_expect_success
'specified branch import HEAD relative range' '
93 test_create_repo r3 && cd r3 &&
94 test_commit --notick start^here &&
96 test_commit --notick one^ &&
97 test_commit --notick two^ &&
98 test_commit --notick three^ &&
99 git checkout --orphan alt &&
100 git read-tree --empty &&
101 git commit --allow-empty -m "empty" &&
102 git clean -d -f -x &&
103 git checkout master &&
104 tg import -d alt HEAD~3..HEAD &&
107 t/three [PATCH] three^
110 tg summary -v -l | tr -s "\\t" " " > ../actual &&
111 test_diff ../expected ../actual &&
118 tg summary --rdeps --heads > ../actual &&
119 test_diff ../expected ../actual &&
120 test_cmp_rev alt "$(tg base t/one)" &&
122 diff --git a/start^here.t b/start^here.t
123 deleted file mode 100644
124 index $startblob..0000000
130 git diff master t/three -- :/ :\!/.topdeps :\!/.topmsg > ../actual &&
131 test_diff ../expected ../actual
133 test_expect_success
'specified branch import foo..HEAD implied relative range' '
134 test_create_repo r4 && cd r4 &&
135 test_commit --notick start^here &&
137 test_commit --notick one^ &&
138 test_commit --notick two^ &&
139 test_commit --notick three^ &&
140 git checkout --orphan alt &&
141 git read-tree --empty &&
142 git commit --allow-empty -m "empty" &&
143 git clean -d -f -x &&
144 git checkout master &&
145 tg import -d alt HEAD~3.. &&
148 t/three [PATCH] three^
151 tg summary -v -l | tr -s "\\t" " " > ../actual &&
152 test_diff ../expected ../actual &&
159 tg summary --rdeps --heads > ../actual &&
160 test_diff ../expected ../actual &&
161 test_cmp_rev alt "$(tg base t/one)" &&
163 diff --git a/start^here.t b/start^here.t
164 deleted file mode 100644
165 index $startblob..0000000
171 git diff master t/three -- :/ :\!/.topdeps :\!/.topmsg > ../actual &&
172 test_diff ../expected ../actual
175 test_expect_success
'specified branch import HEAD..foo implied relative range' '
176 test_create_repo r5 && cd r5 &&
177 test_commit --notick start^here &&
179 test_commit --notick one^ &&
180 test_commit --notick two^ &&
181 test_commit --notick three^ &&
182 git checkout --orphan alt &&
183 git read-tree --empty &&
184 git commit --allow-empty -m "empty" &&
185 git clean -d -f -x &&
187 tg import -d alt ..master &&
190 t/three [PATCH] three^
193 tg summary -v -l | tr -s "\\t" " " > ../actual &&
194 test_diff ../expected ../actual &&
201 tg summary --rdeps --heads > ../actual &&
202 test_diff ../expected ../actual &&
203 test_cmp_rev alt "$(tg base t/one)" &&
205 diff --git a/start^here.t b/start^here.t
206 deleted file mode 100644
207 index $startblob..0000000
213 git diff master t/three -- :/ :\!/.topdeps :\!/.topmsg > ../actual &&
214 test_diff ../expected ../actual
217 test_expect_success
'specified branch import HEAD relative single commit range' '
218 test_create_repo r6 && cd r6 &&
219 test_commit --notick start^here &&
221 test_commit --notick one^ &&
222 test_commit --notick two^ &&
224 test_commit --notick three^ &&
225 git checkout --orphan alt &&
226 git read-tree --empty &&
227 git commit --allow-empty -m "empty" &&
228 git clean -d -f -x &&
229 git checkout master &&
230 tg import -d alt HEAD~^\! &&
234 tg summary -v -l | tr -s "\\t" " " > ../actual &&
235 test_diff ../expected ../actual &&
240 tg summary --rdeps --heads > ../actual &&
241 test_diff ../expected ../actual &&
242 test_cmp_rev alt "$(tg base t/two)" &&
244 diff --git a/one^.t b/one^.t
245 deleted file mode 100644
246 index $oneblob..0000000
251 diff --git a/start^here.t b/start^here.t
252 deleted file mode 100644
253 index $startblob..0000000
259 git diff "test#2" t/two -- :/ :\!/.topdeps :\!/.topmsg > ../actual &&
260 test_diff ../expected ../actual
263 test_expect_success
'default unrelated branch import' '
264 test_create_repo r7 && cd r7 &&
265 test_commit --notick start^here &&
267 test_commit --notick one^ &&
268 test_commit --notick two^ &&
269 test_commit --notick three^ &&
270 git checkout --orphan alt &&
271 git read-tree --empty &&
272 git commit --allow-empty -m "empty" &&
273 git clean -d -f -x &&
274 tg import base..master &&
277 t/three [PATCH] three^
280 tg summary -v -l | tr -s "\\t" " " > ../actual &&
281 test_diff ../expected ../actual &&
288 tg summary --rdeps --heads > ../actual &&
289 test_diff ../expected ../actual &&
290 test_cmp_rev alt "$(tg base t/one)" &&
292 diff --git a/start^here.t b/start^here.t
293 deleted file mode 100644
294 index $startblob..0000000
300 git diff master t/three -- :/ :\!/.topdeps :\!/.topmsg > ../actual &&
301 test_diff ../expected ../actual
304 test_expect_success
'HEAD unrelated branch import' '
305 test_create_repo r8 && cd r8 &&
306 test_commit --notick start^here &&
308 test_commit --notick one^ &&
309 test_commit --notick two^ &&
310 test_commit --notick three^ &&
311 git checkout --orphan alt &&
312 git read-tree --empty &&
313 git commit --allow-empty -m "empty" &&
314 git clean -d -f -x &&
315 tg import -d HEAD base..master &&
318 t/three [PATCH] three^
321 tg summary -v -l | tr -s "\\t" " " > ../actual &&
322 test_diff ../expected ../actual &&
329 tg summary --rdeps --heads > ../actual &&
330 test_diff ../expected ../actual &&
331 test_cmp_rev alt "$(tg base t/one)" &&
333 diff --git a/start^here.t b/start^here.t
334 deleted file mode 100644
335 index $startblob..0000000
341 git diff master t/three -- :/ :\!/.topdeps :\!/.topmsg > ../actual &&
342 test_diff ../expected ../actual
345 test_expect_success
'@ unrelated branch import' '
346 test_create_repo r9 && cd r9 &&
347 test_commit --notick start^here &&
349 test_commit --notick one^ &&
350 test_commit --notick two^ &&
351 test_commit --notick three^ &&
352 git checkout --orphan alt &&
353 git read-tree --empty &&
354 git commit --allow-empty -m "empty" &&
355 git clean -d -f -x &&
356 tg import -d HEAD base..master &&
359 t/three [PATCH] three^
362 tg summary -v -l | tr -s "\\t" " " > ../actual &&
363 test_diff ../expected ../actual &&
370 tg summary --rdeps --heads > ../actual &&
371 test_diff ../expected ../actual &&
372 test_cmp_rev alt "$(tg base t/one)" &&
374 diff --git a/start^here.t b/start^here.t
375 deleted file mode 100644
376 index $startblob..0000000
382 git diff master t/three -- :/ :\!/.topdeps :\!/.topmsg > ../actual &&
383 test_diff ../expected ../actual
386 test_expect_success
'detached implicit HEAD import succeeds with empty .topdeps' '
387 test_create_repo r10a && cd r10a &&
388 test_commit --notick start^here &&
390 test_commit --notick one^ &&
391 test_commit --notick two^ &&
392 test_commit --notick three^ &&
393 git checkout --orphan alt &&
394 git read-tree --empty &&
395 git commit --allow-empty -m "empty" &&
396 git clean -d -f -x &&
397 git checkout --detach HEAD &&
398 tg import base..master &&
399 git checkout t/one &&
401 test_cmp .topdeps expected
404 test_expect_success
'detached explicit HEAD import succeeds with empty .topdeps' '
405 test_create_repo r10b && cd r10b &&
406 test_commit --notick start^here &&
408 test_commit --notick one^ &&
409 test_commit --notick two^ &&
410 test_commit --notick three^ &&
411 git checkout --orphan alt &&
412 git read-tree --empty &&
413 git commit --allow-empty -m "empty" &&
414 git clean -d -f -x &&
415 git checkout --detach HEAD &&
416 tg import -d HEAD base..master &&
417 git checkout t/one &&
419 test_cmp .topdeps expected
422 test_expect_success
'detached explicit @ import succeeds with empty .topdeps' '
423 test_create_repo r10c && cd r10c &&
424 test_commit --notick start^here &&
426 test_commit --notick one^ &&
427 test_commit --notick two^ &&
428 test_commit --notick three^ &&
429 git checkout --orphan alt &&
430 git read-tree --empty &&
431 git commit --allow-empty -m "empty" &&
432 git clean -d -f -x &&
433 git checkout --detach HEAD &&
434 tg import -d @ base..master &&
435 git checkout t/one &&
437 test_cmp .topdeps expected
440 test_expect_success
'unborn implicit HEAD import succeeds with empty .topdeps' '
441 test_create_repo r10d && cd r10d &&
442 test_commit --notick start^here &&
444 test_commit --notick one^ &&
445 test_commit --notick two^ &&
446 test_commit --notick three^ &&
447 git checkout --orphan alt &&
448 git read-tree --empty &&
449 git clean -d -f -x &&
450 tg import base..master &&
451 git checkout t/one &&
453 test_cmp .topdeps expected
456 test_expect_success
'unborn explicit HEAD import succeeds with empty .topdeps' '
457 test_create_repo r10e && cd r10e &&
458 test_commit --notick start^here &&
460 test_commit --notick one^ &&
461 test_commit --notick two^ &&
462 test_commit --notick three^ &&
463 git checkout --orphan alt &&
464 git read-tree --empty &&
465 git clean -d -f -x &&
466 tg import -d HEAD base..master &&
467 git checkout t/one &&
469 test_cmp .topdeps expected
472 test_expect_success
'unborn explicit @ import succeeds with empty .topdeps' '
473 test_create_repo r10f && cd r10f &&
474 test_commit --notick start^here &&
476 test_commit --notick one^ &&
477 test_commit --notick two^ &&
478 test_commit --notick three^ &&
479 git checkout --orphan alt &&
480 git read-tree --empty &&
481 git clean -d -f -x &&
482 tg import -d @ base..master &&
483 git checkout t/one &&
485 test_cmp .topdeps expected
489 ! vcmp
"$git_version" '>=' "2.9" || auh_opt
="--allow-unrelated-histories"
491 test_expect_success
'single commit range requires exactly one parent' '
492 test_create_repo r11 && cd r11 &&
493 test_commit --notick start^here &&
495 git checkout --orphan alt &&
496 git read-tree --empty &&
497 git commit --allow-empty -m empty &&
498 git clean -d -f -x &&
499 git checkout master &&
500 git merge $auh_opt -m merged alt &&
501 test_must_fail tg import HEAD^\! &&
502 test_must_fail tg import base^\!