3 test_description
='summary wayback in time'
11 sqt
="$(test_get_temp squish)" || die not squishy
14 git read-tree
--empty &&
15 git symbolic-ref HEAD refs
/heads
/orphan
19 tab
=" " # single tab in there
20 "$@" >"$sqt" ||
return
21 <"$sqt" tr -s "$tab" " "
24 topbases
="$(tg --top-bases)" && test -n "$topbases" || die
'no top-bases!'
26 test_expect_success
'setup' '
27 test_create_repo pristine && cd pristine &&
28 git checkout --orphan rootcommit &&
29 git read-tree --empty &&
31 git commit --allow-empty -m "empty root commit" &&
33 tg_test_create_tag t/root &&
34 git checkout --orphan branch1 &&
35 git read-tree --empty &&
36 test_commit branch1-start &&
37 git checkout --orphan branch2 &&
38 git read-tree --empty &&
39 test_commit branch2-start &&
40 git checkout --orphan branch3 &&
41 git read-tree --empty &&
42 test_commit branch3-start &&
45 tg_test_create_tag t/branches &&
46 tg_test_create_tag t/branches-only "refs/heads/branch*" &&
47 tg_test_create_branches <<-EOT &&
48 rootbare bare empty root
54 rootdeps --no-topmsg topdeps root
57 root standard root branch
60 annihilated annihilated branch
69 t/branch1 branch1 topgit
72 t/branch2 branch2 topgit
75 t/branch3 branch3 topgit
78 tg_test_create_tag t/midway &&
79 tg_test_create_branches <<-EOT &&
80 reused-1level1 reused with one tg branch below
83 reused-2level1 reused with two tg branches below
87 reused-1level2 reused with one tg branch below
90 reused-2level2 reused with two tg branches below
94 reused-multi multi-level reuse
99 tg_test_create_tag t/reused &&
100 tg_test_create_branches <<-EOT &&
101 boring just a boring commit here move along
110 tg_test_create_tag t/boring1 refs/heads/boring "refs/heads/t/subj*" "$topbases/t/subj*" &&
111 tg_test_create_tag t/all1 &&
112 git checkout -f annihilated &&
114 git commit --allow-empty -m "annihilated not empty" &&
115 git checkout -f t/branch2 &&
116 <.topmsg grep -v -i subject >.topmsg2 &&
117 mv -f .topmsg2 .topmsg &&
118 printf "%s\n" "subject:[PATCH] branch2" " topgit" >> .topmsg &&
121 git commit -m ".topmsg: no space after subject colon" &&
122 git checkout -f t/subjmiss &&
123 <.topmsg grep -v -i subject >.topmsg2 &&
124 mv -f .topmsg2 .topmsg &&
127 git commit -m ".topmsg: whoops, no subject: here" &&
128 git checkout -f t/subjmt &&
129 <.topmsg grep -v -i subject >.topmsg2 &&
130 mv -f .topmsg2 .topmsg &&
131 printf "%s\n" "subJECT: " >> .topmsg &&
134 git commit -m ".topmsg: subject of emptyness" &&
135 tg_test_create_tag t/boring2 refs/heads/boring "refs/heads/t/subj*" "$topbases/t/subj*" &&
136 tg_test_create_tag t/all2 &&
138 git clean -x -d -f &&
144 refs/heads/annihilated
150 refs/heads/reused-1level1
151 refs/heads/reused-1level2
152 refs/heads/reused-2level1
153 refs/heads/reused-2level2
154 refs/heads/reused-multi
157 refs/heads/rootcommit
163 refs/heads/t/subjmiss
165 " > all_refsh || die failed to
make all_refsh
168 $topbases/annihilated
170 $topbases/reused-1level1
171 $topbases/reused-1level2
172 $topbases/reused-2level1
173 $topbases/reused-2level2
174 $topbases/reused-multi
184 " > all_refsb || die failed to
make all_refsb
187 refs/tags/branch1-start
188 refs/tags/branch2-start
189 refs/tags/branch3-start
196 refs/tags/t/branches-only
200 " > all_refst || die failed to
make all_refst
202 if test "$topbases" = "refs/top-bases"; then
203 cat all_refsh all_refst all_refsb
> all_refs
205 cat all_refsh all_refsb all_refst
> all_refs
206 fi || die failed to
make all_refs
209 refs/heads/annihilated
215 refs/heads/reused-1level1
216 refs/heads/reused-1level2
217 refs/heads/reused-2level1
218 refs/heads/reused-2level2
219 refs/heads/reused-multi
222 refs/heads/rootcommit
228 refs/heads/t/subjmiss
230 $topbases/annihilated
232 $topbases/reused-1level1
233 $topbases/reused-1level2
234 $topbases/reused-2level1
235 $topbases/reused-2level2
236 $topbases/reused-multi
246 " > all_tg_refs || die failed to
make all_tg_refs
249 refs/heads/annihilated
256 refs/heads/rootcommit
262 $topbases/annihilated
271 " > midway_refs || die failed to
make midway_refs
274 refs/heads/annihilated
279 refs/heads/reused-1level1
280 refs/heads/reused-1level2
281 refs/heads/reused-2level1
282 refs/heads/reused-2level2
283 refs/heads/reused-multi
286 refs/heads/rootcommit
292 $topbases/annihilated
294 $topbases/reused-1level1
295 $topbases/reused-1level2
296 $topbases/reused-2level1
297 $topbases/reused-2level2
298 $topbases/reused-multi
306 " > reused_refs || die failed to
make reused_refs
310 refs/heads/t/subjmiss
314 " > boring_refs || die failed to
make boring_refs
316 squish
printf "%s" "\
317 annihilated branch annihilated (annihilated)
318 basebare branch basebare (bare branch)
319 reused-1level1 [PATCH] reused with one tg branch below
320 reused-1level2 [PATCH] reused with one tg branch below
321 reused-2level1 [PATCH] reused with two tg branches below
322 reused-2level2 [PATCH] reused with two tg branches below
323 reused-multi [PATCH] multi-level reuse
324 root [PATCH] standard root branch
325 rootbare branch rootbare (no commits)
326 rootdeps branch rootdeps (missing .topmsg)
327 rootmsg [PATCH] topmsg root
328 t/branch1 [PATCH] branch1 topgit
329 t/branch2 [PATCH] branch2 topgit
330 t/branch3 [PATCH] branch3 topgit
331 t/subjmiss branch t/subjmiss (missing \"Subject:\" in .topmsg)
332 t/subjmt branch t/subjmt (empty \"Subject:\" in .topmsg)
333 " > pristine_full_list || die failed to
make pristine_full_list
335 squish
printf "%s" "\
336 annihilated branch annihilated (annihilated)
337 basebare branch basebare (bare branch)
338 reused-1level1 [PATCH] reused with one tg branch below
339 reused-1level2 [PATCH] reused with one tg branch below
340 reused-2level1 [PATCH] reused with two tg branches below
341 reused-2level2 [PATCH] reused with two tg branches below
342 reused-multi [PATCH] multi-level reuse
343 root [PATCH] standard root branch
344 rootbare branch rootbare (no commits)
345 rootdeps branch rootdeps (missing .topmsg)
346 rootmsg [PATCH] topmsg root
347 t/branch1 [PATCH] branch1 topgit
348 t/branch2 [PATCH] branch2 topgit
349 t/branch3 [PATCH] branch3 topgit
350 t/subjmiss [PATCH] branch t/subjmiss
351 t/subjmt [PATCH] branch t/subjmt
352 " > pristine_boring_list || die failed to
make pristine_boring_list
354 squish
printf "%s" "\
355 annihilated branch annihilated (no commits)
356 basebare branch basebare (bare branch)
357 reused-1level1 [PATCH] reused with one tg branch below
358 reused-1level2 [PATCH] reused with one tg branch below
359 reused-2level1 [PATCH] reused with two tg branches below
360 reused-2level2 [PATCH] reused with two tg branches below
361 reused-multi [PATCH] multi-level reuse
362 root [PATCH] standard root branch
363 rootbare branch rootbare (no commits)
364 rootdeps branch rootdeps (missing .topmsg)
365 rootmsg [PATCH] topmsg root
366 t/branch1 [PATCH] branch1 topgit
367 t/branch2 [PATCH] branch2 topgit
368 t/branch3 [PATCH] branch3 topgit
369 t/subjmiss branch t/subjmiss (missing \"Subject:\" in .topmsg)
370 t/subjmt branch t/subjmt (empty \"Subject:\" in .topmsg)
371 " > pristine_fullb4_list || die failed to
make pristine_fullb4_list
373 squish
printf "%s" "\
374 annihilated branch annihilated (no commits)
375 basebare branch basebare (bare branch)
376 reused-1level1 [PATCH] reused with one tg branch below
377 reused-1level2 [PATCH] reused with one tg branch below
378 reused-2level1 [PATCH] reused with two tg branches below
379 reused-2level2 [PATCH] reused with two tg branches below
380 reused-multi [PATCH] multi-level reuse
381 root [PATCH] standard root branch
382 rootbare branch rootbare (no commits)
383 rootdeps branch rootdeps (missing .topmsg)
384 rootmsg [PATCH] topmsg root
385 t/branch1 [PATCH] branch1 topgit
386 t/branch2 [PATCH] branch2 topgit
387 t/branch3 [PATCH] branch3 topgit
388 t/subjmiss [PATCH] branch t/subjmiss
389 t/subjmt [PATCH] branch t/subjmt
390 " > pristine_boringb4_list || die failed to
make pristine_boring_list
392 squish
printf "%s" "\
393 annihilated branch annihilated (no commits)
394 basebare branch basebare (bare branch)
395 reused-1level1 [PATCH] reused with one tg branch below
396 reused-1level2 [PATCH] reused with one tg branch below
397 reused-2level1 [PATCH] reused with two tg branches below
398 reused-2level2 [PATCH] reused with two tg branches below
399 reused-multi [PATCH] multi-level reuse
400 root [PATCH] standard root branch
401 rootbare branch rootbare (no commits)
402 rootdeps branch rootdeps (missing .topmsg)
403 rootmsg [PATCH] topmsg root
404 t/branch1 [PATCH] branch1 topgit
405 t/branch2 [PATCH] branch2 topgit
406 t/branch3 [PATCH] branch3 topgit
407 t/subjmiss branch t/subjmiss (missing \"Subject:\" in .topmsg)
408 t/subjmt branch t/subjmt (empty \"Subject:\" in .topmsg)
409 " > pristine_fullb4b1_list || die failed to
make pristine_fullb4b1_list
411 squish
printf "%s" "\
412 annihilated branch annihilated (no commits)
413 basebare branch basebare (bare branch)
414 root [PATCH] standard root branch
415 rootbare branch rootbare (no commits)
416 rootdeps branch rootdeps (missing .topmsg)
417 rootmsg [PATCH] topmsg root
418 t/branch1 [PATCH] branch1 topgit
419 t/branch2 [PATCH] branch2 topgit
420 t/branch3 [PATCH] branch3 topgit
421 " > pristine_midway_list || die failed to
make pristine_midway_list
423 squish
printf "%s" "\
424 annihilated branch annihilated (no commits)
425 basebare branch basebare (bare branch)
426 reused-1level1 [PATCH] reused with one tg branch below
427 reused-1level2 [PATCH] reused with one tg branch below
428 reused-2level1 [PATCH] reused with two tg branches below
429 reused-2level2 [PATCH] reused with two tg branches below
430 reused-multi [PATCH] multi-level reuse
431 root [PATCH] standard root branch
432 rootbare branch rootbare (no commits)
433 rootdeps branch rootdeps (missing .topmsg)
434 rootmsg [PATCH] topmsg root
435 t/branch1 [PATCH] branch1 topgit
436 t/branch2 [PATCH] branch2 topgit
437 t/branch3 [PATCH] branch3 topgit
438 " > pristine_reused_list || die failed to
make pristine_reused_list
440 squish
printf "%s" "\
441 t/subjmiss [PATCH] branch t/subjmiss
442 t/subjmt [PATCH] branch t/subjmt
443 " > pristine_boring1_list || die failed to
make pristine_boring1_list
445 squish
printf "%s" "\
446 t/subjmiss branch t/subjmiss (missing \"Subject:\" in .topmsg)
447 t/subjmt branch t/subjmt (empty \"Subject:\" in .topmsg)
448 " > pristine_boring2_list || die failed to
make pristine_boring2_list
450 squish
printf "%s" "\
451 basebare branch basebare (bare branch)
452 0 reused-1level1 [PATCH] reused with one tg branch below
453 0 reused-1level2 [PATCH] reused with one tg branch below
454 0 D * reused-2level1 [PATCH] reused with two tg branches below
455 0 D * reused-2level2 [PATCH] reused with two tg branches below
456 0 D reused-multi [PATCH] multi-level reuse
457 0 root [PATCH] standard root branch
458 0 rootdeps branch rootdeps (missing .topmsg)
459 0 rootmsg [PATCH] topmsg root
460 0 t/branch1 [PATCH] branch1 topgit
461 0 * t/branch2 [PATCH] branch2 topgit
462 0 * t/branch3 [PATCH] branch3 topgit
463 0 t/subjmiss branch t/subjmiss (missing \"Subject:\" in .topmsg)
464 0 t/subjmt branch t/subjmt (empty \"Subject:\" in .topmsg)
465 " > pristine_full_summary || die failed to
make pristine_full_summary
467 squish
printf "%s" "\
468 basebare branch basebare (bare branch)
469 0 reused-1level1 [PATCH] reused with one tg branch below
470 0 reused-1level2 [PATCH] reused with one tg branch below
471 0 D * reused-2level1 [PATCH] reused with two tg branches below
472 0 D * reused-2level2 [PATCH] reused with two tg branches below
473 0 D reused-multi [PATCH] multi-level reuse
474 0 root [PATCH] standard root branch
475 0 rootdeps branch rootdeps (missing .topmsg)
476 0 rootmsg [PATCH] topmsg root
477 0 t/branch1 [PATCH] branch1 topgit
478 0 * t/branch2 [PATCH] branch2 topgit
479 0 * t/branch3 [PATCH] branch3 topgit
480 0 t/subjmiss [PATCH] branch t/subjmiss
481 0 t/subjmt [PATCH] branch t/subjmt
482 " > pristine_boring_summary || die failed to
make pristine_boring_summary
484 squish
printf "%s" "\
485 basebare branch basebare (bare branch)
486 0 root [PATCH] standard root branch
487 0 rootdeps branch rootdeps (missing .topmsg)
488 0 rootmsg [PATCH] topmsg root
489 0 t/branch1 [PATCH] branch1 topgit
490 0 t/branch2 [PATCH] branch2 topgit
491 0 t/branch3 [PATCH] branch3 topgit
492 " > pristine_midway_summary || die failed to
make pristine_midway_summary
494 squish
printf "%s" "\
495 basebare branch basebare (bare branch)
496 0 reused-1level1 [PATCH] reused with one tg branch below
497 0 reused-1level2 [PATCH] reused with one tg branch below
498 0 D * reused-2level1 [PATCH] reused with two tg branches below
499 0 D * reused-2level2 [PATCH] reused with two tg branches below
500 0 D reused-multi [PATCH] multi-level reuse
501 0 root [PATCH] standard root branch
502 0 rootdeps branch rootdeps (missing .topmsg)
503 0 rootmsg [PATCH] topmsg root
504 0 t/branch1 [PATCH] branch1 topgit
505 0 * t/branch2 [PATCH] branch2 topgit
506 0 * t/branch3 [PATCH] branch3 topgit
507 " > pristine_reused_summary || die failed to
make pristine_reused_summary
509 squish
printf "%s" "\
510 0 t/subjmiss [PATCH] branch t/subjmiss
511 0 t/subjmt [PATCH] branch t/subjmt
512 " > pristine_boring1_summary || die failed to
make pristine_boring1_summary
514 squish
printf "%s" "\
515 0 t/subjmiss branch t/subjmiss (missing \"Subject:\" in .topmsg)
516 0 t/subjmt branch t/subjmt (empty \"Subject:\" in .topmsg)
517 " > pristine_boring2_summary || die failed to
make pristine_boring2_summary
519 test_expect_success
'verify list' '
520 squish tg -C copy summary -vvl >actual &&
521 test_diff pristine_full_list actual &&
522 squish tg -C copy -w : summary -vvl > actual &&
523 test_diff pristine_full_list actual &&
524 squish tg -C copy -w : summary -vvl > actual &&
525 test_diff pristine_full_list actual &&
526 squish tg -C copy -w : shell tg summary -vvl > actual &&
527 test_diff pristine_full_list actual &&
528 squish tg -C copy -w t/all2 summary -vvl > actual &&
529 test_diff pristine_full_list actual &&
530 squish tg -C copy -w t/all2 shell tg summary -vvl> actual &&
531 test_diff pristine_full_list actual
534 test_expect_success
'verify summary' '
535 squish tg -C copy summary >actual &&
536 test_diff pristine_full_summary actual &&
537 squish tg -C copy -w : summary > actual &&
538 test_diff pristine_full_summary actual &&
539 squish tg -C copy -w : summary > actual &&
540 test_diff pristine_full_summary actual &&
541 squish tg -C copy -w : shell tg summary > actual &&
542 test_diff pristine_full_summary actual &&
543 squish tg -C copy -w t/all2 summary > actual &&
544 test_diff pristine_full_summary actual &&
545 squish tg -C copy -w t/all2 shell tg summary > actual &&
546 test_diff pristine_full_summary actual
549 test_expect_success
'wayback list' '
551 for wtag in t/root t/branches t/branches-only; do
552 squish tg -C copy -w "$wtag" summary -vvl >actual &&
553 test_diff pristine_full_list actual &&
554 tg -C copy -w ":$wtag" summary -vvl >actual &&
555 test_diff expected actual || return
557 squish tg -C copy -w t/midway summary -vvl >actual &&
558 test_diff pristine_fullb4_list actual &&
559 squish tg -C copy -w :t/midway summary -vvl >actual &&
560 test_diff pristine_midway_list actual &&
561 squish tg -C copy -w t/reused summary -vvl >actual &&
562 test_diff pristine_fullb4_list actual &&
563 squish tg -C copy -w :t/reused summary -vvl >actual &&
564 test_diff pristine_reused_list actual &&
565 squish tg -C copy -w t/boring1 summary -vvl >actual &&
566 test_diff pristine_boring_list actual &&
567 squish tg -C copy -w :t/boring1 summary -vvl >actual &&
568 test_diff pristine_boring1_list actual &&
569 squish tg -C copy -w t/all1 summary -vvl >actual &&
570 test_diff pristine_boringb4_list actual &&
571 squish tg -C copy -w :t/all1 summary -vvl >actual &&
572 test_diff pristine_boringb4_list actual &&
573 squish tg -C copy -w t/boring2 summary -vvl >actual &&
574 test_diff pristine_full_list actual &&
575 squish tg -C copy -w :t/boring2 summary -vvl >actual &&
576 test_diff pristine_boring2_list actual
579 test_expect_success
'wayback summary' '
581 for wtag in t/root t/branches t/branches-only; do
582 squish tg -C copy -w "$wtag" summary >actual &&
583 test_diff pristine_full_summary actual &&
584 tg -C copy -w ":$wtag" summary >actual &&
585 test_diff expected actual || return
587 squish tg -C copy -w t/midway summary >actual &&
588 test_diff pristine_full_summary actual &&
589 squish tg -C copy -w :t/midway summary >actual &&
590 test_diff pristine_midway_summary actual &&
591 squish tg -C copy -w t/reused summary >actual &&
592 test_diff pristine_full_summary actual &&
593 squish tg -C copy -w :t/reused summary >actual &&
594 test_diff pristine_reused_summary actual &&
595 squish tg -C copy -w t/boring1 summary >actual &&
596 test_diff pristine_boring_summary actual &&
597 squish tg -C copy -w :t/boring1 summary >actual &&
598 test_diff pristine_boring1_summary actual &&
599 squish tg -C copy -w t/all1 summary >actual &&
600 test_diff pristine_boring_summary actual &&
601 squish tg -C copy -w :t/all1 summary >actual &&
602 test_diff pristine_boring_summary actual &&
603 squish tg -C copy -w t/boring2 summary >actual &&
604 test_diff pristine_full_summary actual &&
605 squish tg -C copy -w :t/boring2 summary >actual &&
606 test_diff pristine_boring2_summary actual
609 test_expect_success
'wayback refs' '
610 printf "%s\n" "refs/heads/rootcommit" >expected &&
611 tg -C copy -w t/root shell git for-each-ref --format="%\\(refname\\)" > actual &&
612 test_diff all_refs actual &&
613 tg -C copy -w :t/root shell git for-each-ref --format="%\\(refname\\)" > actual &&
614 test_diff expected actual &&
615 printf "%s\n" "refs/heads/branch1" "refs/heads/branch2" "refs/heads/branch3" \
616 "refs/heads/rootcommit" >expected &&
617 tg -C copy -w t/branches shell -q git for-each-ref --format="%(refname)" > actual &&
618 test_diff all_refs actual &&
619 tg -C copy -w :t/branches shell -q git for-each-ref --format="%(refname)" > actual &&
620 test_diff expected actual &&
621 printf "%s\n" "refs/heads/branch1" "refs/heads/branch2" "refs/heads/branch3" >expected &&
622 tg -C copy -w t/branches-only shell -q git for-each-ref --format="%(refname)" > actual &&
623 test_diff all_refs actual &&
624 tg -C copy -w :t/branches-only shell -q git for-each-ref --format="%(refname)" > actual &&
625 test_diff expected actual &&
626 tg -C copy -w t/midway shell -q git for-each-ref --format="%(refname)" > actual &&
627 test_diff all_refs actual &&
628 tg -C copy -w :t/midway shell -q git for-each-ref --format="%(refname)" > actual &&
629 test_diff midway_refs actual &&
630 tg -C copy -w t/reused shell -q git for-each-ref --format="%(refname)" > actual &&
631 test_diff all_refs actual &&
632 tg -C copy -w :t/reused shell -q git for-each-ref --format="%(refname)" > actual &&
633 test_diff reused_refs actual &&
634 tg -C copy -w t/all1 shell -q git for-each-ref --format="%(refname)" > actual &&
635 test_diff all_refs actual &&
636 tg -C copy -w :t/all1 shell -q git for-each-ref --format="%(refname)" > actual &&
637 test_diff all_tg_refs actual &&
638 tg -C copy -w t/boring1 shell -q git for-each-ref --format="%(refname)" > actual &&
639 test_diff all_refs actual &&
640 tg -C copy -w :t/boring1 shell -q git for-each-ref --format="%(refname)" > actual &&
641 test_diff boring_refs actual &&
642 tg -C copy -w t/all2 shell -q git for-each-ref --format="%(refname)" > actual &&
643 test_diff all_refs actual &&
644 tg -C copy -w :t/all2 shell -q git for-each-ref --format="%(refname)" > actual &&
645 test_diff all_tg_refs actual &&
646 tg -C copy -w t/boring2 shell -q git for-each-ref --format="%(refname)" > actual &&
647 test_diff all_refs actual &&
648 tg -C copy -w :t/boring2 shell -q git for-each-ref --format="%(refname)" > actual &&
649 test_diff boring_refs actual
652 test_expect_success
'wayback directory refs' '
653 tg -C copy -w :t/midway shell --directory "$PWD/newdir" : &&
654 git -C newdir for-each-ref --format="%(refname)" > actual &&
655 test_diff midway_refs actual