3 test_description
='check summary output'
12 git read-tree
--empty &&
13 git symbolic-ref HEAD refs
/heads
/orphan
17 tab
=" " # single tab in there
21 test_expect_success
'setup' '
22 test_create_repo pristine && cd pristine &&
23 git checkout --orphan rootcommit &&
24 git read-tree --empty &&
26 git commit --allow-empty -m "empty root commit" &&
28 git checkout --orphan branch1 &&
29 git read-tree --empty &&
30 test_commit branch1-start &&
31 git checkout --orphan branch2 &&
32 git read-tree --empty &&
33 test_commit branch2-start &&
34 git checkout --orphan branch3 &&
35 git read-tree --empty &&
36 test_commit branch3-start &&
39 tg_test_create_branches <<-EOT &&
40 rootbare bare empty root
46 rootdeps --no-topmsg topdeps root
49 root standard root branch
52 annihilated annihilated branch
61 t/branch1 branch1 topgit
64 t/branch2 branch2 topgit
67 t/branch3 branch3 topgit
70 reused-1level1 reused with one tg branch below
73 reused-2level1 reused with two tg branches below
77 reused-1level2 reused with one tg branch below
80 reused-2level2 reused with two tg branches below
84 reused-multi multi-level reuse
90 git checkout -f annihilated &&
92 git commit --allow-empty -m "annihilated not empty" &&
93 git checkout -f t/branch2 &&
94 <.topmsg grep -v -i subject >.topmsg2 &&
95 mv -f .topmsg2 .topmsg &&
96 printf "%s\n" "subject:[PATCH] branch2" " topgit" >> .topmsg &&
99 git commit -m ".topmsg: no space after subject colon" &&
101 git clean -x -d -f &&
106 test_expect_success
'bad usage' '
107 cd copy && reset_repo &&
110 test_must_fail tg summary --rdeps && # bad HEAD default
111 test_must_fail tg summary --rdeps-once && # bad HEAD default
112 test_must_fail tg summary --rdeps-full && # bad HEAD default
113 test_must_fail tg summary --with-deps && # bad HEAD default
114 test_must_fail tg summary --without-deps && # bad HEAD default
115 test_must_fail tg summary --deps-only && # bad HEAD default
116 test_must_fail tg summary --deps HEAD && # bad HEAD (--deps does not default)
118 git update-ref --no-deref HEAD branch1 &&
121 test_must_fail tg summary --rdeps && # bad HEAD default
122 test_must_fail tg summary --rdeps-once && # bad HEAD default
123 test_must_fail tg summary --rdeps-full && # bad HEAD default
124 test_must_fail tg summary --with-deps && # bad HEAD default
125 test_must_fail tg summary --without-deps && # bad HEAD default
126 test_must_fail tg summary --deps-only && # bad HEAD default
127 test_must_fail tg summary --deps HEAD && # bad HEAD (--deps does not default)
129 git symbolic-ref HEAD refs/heads/branch3 &&
131 # HEAD is a non-TopGit branch
132 test_must_fail tg summary --rdeps && # bad HEAD default
133 test_must_fail tg summary --rdeps-once && # bad HEAD default
134 test_must_fail tg summary --rdeps-full && # bad HEAD default
135 test_must_fail tg summary --with-deps && # bad HEAD default
136 test_must_fail tg summary --without-deps && # bad HEAD default
137 test_must_fail tg summary --deps-only && # bad HEAD default
138 test_must_fail tg summary --deps HEAD && # bad HEAD (--deps does not default)
144 basebare branch basebare (bare branch)
145 0 reused-1level1 [PATCH] reused with one tg branch below
146 0 reused-1level2 [PATCH] reused with one tg branch below
147 0 D * reused-2level1 [PATCH] reused with two tg branches below
148 0 D * reused-2level2 [PATCH] reused with two tg branches below
149 0 D reused-multi [PATCH] multi-level reuse
150 0 root [PATCH] standard root branch
151 0 rootdeps branch rootdeps (missing .topmsg)
152 0 rootmsg [PATCH] topmsg root
153 0 t/branch1 [PATCH] branch1 topgit
154 0 * t/branch2 [PATCH] branch2 topgit
155 0 * t/branch3 [PATCH] branch3 topgit
156 " > pristine_full_summary.raw ||
157 die failed to
make pristine_full_summary.raw
158 < pristine_full_summary.raw squish
> pristine_full_summary ||
159 die failed to
make pristine_full_summary
162 0 reused-1level1 [PATCH] reused with one tg branch below
163 0 D * reused-2level1 [PATCH] reused with two tg branches below
164 0 D * reused-2level2 [PATCH] reused with two tg branches below
165 0 D reused-multi [PATCH] multi-level reuse
166 0 t/branch1 [PATCH] branch1 topgit
167 0 * t/branch2 [PATCH] branch2 topgit
168 0 * t/branch3 [PATCH] branch3 topgit
169 " > pristine_multi_summary.raw ||
170 die failed to
make pristine_multi_summary.raw
171 < pristine_multi_summary.raw squish
> pristine_multi_summary ||
172 die failed to
make pristine_multi_summary
175 0 D reused-2level1 [PATCH] reused with two tg branches below
176 0 t/branch1 [PATCH] branch1 topgit
177 0 * t/branch2 [PATCH] branch2 topgit
178 " > pristine_2level1_summary.raw ||
179 die failed to
make pristine_2level1_summary.raw
180 < pristine_2level1_summary.raw squish
> pristine_2level1_summary ||
181 die failed to
make pristine_2level1_summary
196 " >pristine_list || die failed to
make pristine_list
199 reused-1level1 t/branch1
200 reused-1level2 reused-1level1
201 reused-2level1 t/branch1
202 reused-2level1 t/branch2
203 reused-2level2 reused-1level1
204 reused-2level2 reused-2level1
205 reused-multi reused-2level1
206 reused-multi t/branch3
207 reused-multi reused-2level2
211 " >pristine_deps || die failed to
make pristine_deps
229 " >pristine_deps_only_all || die failed to
make pristine_deps_only_all
243 " >pristine_sort || die failed to
make pristine_sort
246 '# GraphViz output; pipe to:
247 # | dot -Tpng -o <output>
255 label="TopGit Layout\n\n\n"
261 "reused-1level1" -> "t/branch1";
262 "reused-1level2" -> "reused-1level1";
263 "reused-2level1" -> "t/branch1";
264 "reused-2level1" -> "t/branch2";
265 "reused-2level2" -> "reused-1level1";
266 "reused-2level2" -> "reused-2level1";
267 "reused-multi" -> "reused-2level1";
268 "reused-multi" -> "t/branch3";
269 "reused-multi" -> "reused-2level2";
270 "t/branch1" -> "branch1";
271 "t/branch2" -> "branch2";
272 "t/branch3" -> "branch3";
274 ' >pristine_graphviz || die failed to
make pristine_graphviz
283 " >pristine_heads || die failed to
make pristine_heads
286 basebare branch basebare (bare branch)
287 reused-1level1 [PATCH] reused with one tg branch below
288 reused-1level2 [PATCH] reused with one tg branch below
289 reused-2level1 [PATCH] reused with two tg branches below
290 reused-2level2 [PATCH] reused with two tg branches below
291 reused-multi [PATCH] multi-level reuse
292 root [PATCH] standard root branch
293 rootbare branch rootbare (no commits)
294 rootdeps branch rootdeps (missing .topmsg)
295 rootmsg [PATCH] topmsg root
296 t/branch1 [PATCH] branch1 topgit
297 t/branch2 [PATCH] branch2 topgit
298 t/branch3 [PATCH] branch3 topgit
299 " > pristine_list_verbose.raw ||
300 die failed to
make pristine_list_verbose.raw
301 < pristine_list_verbose.raw squish
> pristine_list_verbose ||
302 die failed to
make pristine_list_verbose
305 basebare branch basebare (bare branch)
306 0 reused-1level2 [PATCH] reused with one tg branch below
307 0 D reused-multi [PATCH] multi-level reuse
308 0 root [PATCH] standard root branch
309 0 rootdeps branch rootdeps (missing .topmsg)
310 0 rootmsg [PATCH] topmsg root
311 " > pristine_heads_only.raw ||
312 die failed to
make pristine_heads_only.raw
313 < pristine_heads_only.raw squish
> pristine_heads_only ||
314 die failed to
make pristine_heads_only
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 " > pristine_list_verbose2.raw ||
332 die failed to
make pristine_list_verbose2.raw
333 < pristine_list_verbose2.raw squish
> pristine_list_verbose2 ||
334 die failed to
make pristine_list_verbose2
367 " >pristine_rdeps_full_heads || die failed to
make pristine_rdeps_full_heads
395 " >pristine_rdeps_once_heads || die failed to
make pristine_rdeps_once_heads
415 " >pristine_rdeps_full_multi || die failed to
make pristine_rdeps_full_multi
430 " >pristine_rdeps_once_multi || die failed to
make pristine_rdeps_once_multi
442 " >pristine_rdeps_full_2level2 || die failed to
make pristine_rdeps_full_2level2
453 " >pristine_rdeps_once_2level2 || die failed to
make pristine_rdeps_once_2level2
455 test_expect_success
'list' '
456 cd copy && reset_repo &&
457 tg summary --list > actual.raw &&
458 squish < actual.raw > actual &&
459 test_diff ../pristine_list actual
462 test_expect_success
'list verbose' '
463 cd copy && reset_repo &&
464 tg summary --verbose --list > actual.raw &&
465 squish < actual.raw > actual &&
466 test_diff ../pristine_list_verbose actual
469 test_expect_success
'list verbose verbose' '
470 cd copy && reset_repo &&
471 tg summary --verbose --verbose --list > actual.raw &&
472 squish < actual.raw > actual &&
473 test_diff ../pristine_list_verbose2 actual
476 test_expect_success
'deps' '
477 cd copy && reset_repo &&
478 tg summary --deps > actual &&
479 test_diff ../pristine_deps actual
482 test_expect_success
'deps only all' '
483 cd copy && reset_repo &&
484 tg summary --deps-only --all > actual &&
485 test_diff ../pristine_deps_only_all actual
488 test_expect_success
'sort' '
489 cd copy && reset_repo &&
490 # the problem with tsort is that it is only guaranteed to produce "a"
491 # topological sort. If there is more than one possible correct answer
492 # which one it produces is left unspecified (i.e. up to the
493 # implementation). So we sort the output. Ugh.
494 sort < ../pristine_sort > expected &&
495 tg summary --sort > actual.raw &&
496 sort < actual.raw > actual &&
497 test_diff expected actual &&
498 # but then we also generate a "--sort" output for reused-1level2 which
499 # we do NOT sort because it has only one valid topological ordering
500 # which should therefore provide the best of both worlds.
507 tg summary --sort reused-1level2 > actual &&
508 test_diff expected actual
511 test_expect_success
'graphviz' '
512 cd copy && reset_repo &&
513 tg summary --graphviz > actual &&
514 test_diff ../pristine_graphviz actual
517 test_expect_success
'heads' '
518 cd copy && reset_repo &&
519 tg summary --heads > actual &&
520 test_diff ../pristine_heads actual
523 test_expect_success
'summary heads only' '
524 cd copy && reset_repo &&
525 tg summary --heads-only > actual.raw &&
526 squish < actual.raw > actual &&
527 test_diff ../pristine_heads_only actual
530 test_expect_success
'summary with orphan HEAD' '
531 cd copy && reset_repo &&
532 tg summary > actual.raw &&
533 squish < actual.raw > actual &&
534 test_diff ../pristine_full_summary actual
537 test_expect_success
'summary with detached HEAD' '
538 cd copy && reset_repo &&
539 git update-ref --no-deref HEAD t/branch1 &&
540 tg summary > actual.raw &&
541 squish < actual.raw > actual &&
542 test_diff ../pristine_full_summary actual
545 test_expect_success
'summary with non-TopGit HEAD' '
546 cd copy && reset_repo &&
547 git symbolic-ref HEAD refs/heads/branch2 &&
548 tg summary > actual.raw &&
549 squish < actual.raw > actual &&
550 test_diff ../pristine_full_summary actual
553 test_expect_success
'summary with TopGit HEAD' '
554 cd copy && reset_repo &&
555 < ../pristine_full_summary sed "/reused-2level1/s/^ />/" > expected &&
556 git symbolic-ref HEAD refs/heads/reused-2level1 &&
557 tg summary > actual.raw &&
558 squish < actual.raw > actual &&
559 test_diff expected actual
562 test_expect_success
'summary with TopGit base HEAD' '
563 cd copy && reset_repo &&
564 < ../pristine_full_summary sed "/reused-2level1/s/^ />/" > expected &&
565 git symbolic-ref HEAD "$(tg --top-bases)/reused-2level1" &&
566 tg summary > actual.raw &&
567 squish < actual.raw > actual &&
568 test_diff expected actual
571 test_expect_success
'rdeps heads' '
572 cd copy && reset_repo &&
573 tg summary --rdeps --heads > actual &&
574 test_diff ../pristine_rdeps_once_heads actual
577 test_expect_success
'rdeps-once heads' '
578 cd copy && reset_repo &&
579 tg summary --rdeps-once --heads > actual &&
580 test_diff ../pristine_rdeps_once_heads actual
583 test_expect_success
'rdeps-full heads' '
584 cd copy && reset_repo &&
585 tg summary --rdeps-full --heads > actual &&
586 test_diff ../pristine_rdeps_full_heads actual
589 test_expect_success
'rdeps-once reused-multi' '
590 cd copy && reset_repo &&
591 tg summary --rdeps-once reused-multi > actual &&
592 test_diff ../pristine_rdeps_once_multi actual
595 test_expect_success
'rdeps-full reused-multi' '
596 cd copy && reset_repo &&
597 tg summary --rdeps-full reused-multi > actual &&
598 test_diff ../pristine_rdeps_full_multi actual
601 test_expect_success
'rdeps-once reused-2level2' '
602 cd copy && reset_repo &&
603 tg summary --rdeps-once reused-2level2 > actual &&
604 test_diff ../pristine_rdeps_once_2level2 actual
607 test_expect_success
'rdeps-full reused-2level2' '
608 cd copy && reset_repo &&
609 tg summary --rdeps-full reused-2level2 > actual &&
610 test_diff ../pristine_rdeps_full_2level2 actual
613 test_expect_success
'summary with-deps multi' '
614 cd copy && reset_repo &&
615 tg summary --with-deps reused-multi > actual.raw &&
616 squish < actual.raw > actual &&
617 test_diff ../pristine_multi_summary actual
620 test_expect_success
'summary with-related multi' '
621 cd copy && reset_repo &&
622 tg summary --with-related reused-multi > actual.raw &&
623 squish < actual.raw > actual &&
624 test_diff ../pristine_multi_summary actual
627 test_expect_success
'summary with-deps 2level1' '
628 cd copy && reset_repo &&
629 tg summary --with-deps reused-2level1 > actual.raw &&
630 squish < actual.raw > actual &&
631 test_diff ../pristine_2level1_summary actual
634 test_expect_success
'summary with-related 2level1' '
635 cd copy && reset_repo &&
636 tg summary --with-related reused-2level1 > actual.raw &&
637 squish < actual.raw > actual &&
638 test_diff ../pristine_multi_summary actual
641 test_expect_success
'summary @ with 2level1 HEAD' '
642 cd copy && reset_repo &&
643 < ../pristine_multi_summary sed "/reused-2level1/s/^ />/" > expected &&
644 git symbolic-ref HEAD "refs/heads/reused-2level1" &&
645 tg summary @ > actual.raw &&
646 squish < actual.raw > actual &&
647 test_diff expected actual
650 test_expect_success
'summary @ @ with 2level1 HEAD' '
651 cd copy && reset_repo &&
652 < ../pristine_2level1_summary sed "/reused-2level1/s/^ />/" > expected &&
653 git symbolic-ref HEAD "refs/heads/reused-2level1" &&
654 tg summary @ @ > actual.raw &&
655 squish < actual.raw > actual &&
656 test_diff expected actual