t4400: test -i and -w informational options
[topgit/pro.git] / t / t4400-options-iw.sh
blobb105fd4df85978a549e1364eec1909557fb1ea41
1 #!/bin/sh
3 test_description='use of -i/-w options with tg commands that support them
5 These are the -i and -w options that cause the index or working tree to be
6 used, respectively, not any other meanings they might have.
8 Specifically files, mail, next, patch, prev and summary subcommands.
11 . ./test-lib.sh
13 test_plan 36
15 trim() {
16 _cmd="$1"
17 shift
18 _ec=0
19 eval "$_cmd "'"$@" >_tmp' || _ec=$?
20 tr -s '\t ' ' ' <_tmp
21 return $_ec
24 from="$(git var GIT_AUTHOR_IDENT)" && test -n "$from" || die
25 from="${from%>*}>"
27 REAL_GIT="$( { "unset" -f git; } >/dev/null 2>&1 || :; command -v "${GIT_PATH:-git}" )" || die
29 test_expect_success 'setup' '
30 git config core.abbrev 16 &&
31 mkdir -p .git/info &&
32 printf "%s\n" _tmp actual expected >.git/info/exclude &&
33 tg_test_create_branches <<-EOT &&
34 branch1
35 :::
37 t/branch1
38 branch1
40 branch2
41 :::
43 t/branch2
44 branch2
46 branch3
47 :::
49 t/branch3
50 branch3
52 branch4
53 :::
55 t/branch4
56 branch4
58 branch5
59 :::
61 t/branch5
62 branch5
64 t/primary
65 t/branch1
67 t/secondary
68 t/branch2
70 EOT
71 git checkout -f t/secondary &&
72 git clean -f &&
73 >f3 && >f4 && >f5 &&
74 git add f3 f4 f5 &&
75 test_tick &&
76 git commit -m "f3-5" &&
77 tg_test_create_branches <<-EOT &&
78 t/primary2
79 t/primary
81 t/secondary2
82 t/secondary
84 EOT
85 echo t/branch2 >expected &&
86 test_cmp .topdeps expected &&
87 echo "From: $from" >expected &&
88 echo "Subject: [PATCH] branch t/secondary" >>expected &&
89 test_cmp .topmsg expected &&
90 mkdir -p .git/dummy && test -d .git/dummy &&
91 write_script .git/dummy/git <<-EOT &&
92 test "\$1" = "send-email" && test \$# -ge 2 &&
93 eval exec cat "\\"\\\$\$#\\"" ||
94 exec "${REAL_GIT:-false}" "\$@"
95 EOT
96 PATH="$PWD/.git/dummy:$PATH" \
97 command git send-email foo bar you hoo .topmsg >actual &&
98 test_cmp actual expected
101 test_expect_success LASTOK 'verify setup' '
102 cat <<-EOT >expected &&
103 t/branch3
104 branch3
106 t/branch4
107 branch4
109 t/branch5
110 branch5
112 t/primary2
113 t/primary
114 t/branch1
115 branch1
117 t/secondary2
118 t/secondary
119 t/branch2
120 branch2
122 trim tg summary --rdeps --heads >actual &&
123 test_cmp actual expected &&
124 cat <<-EOT >expected &&
125 0 t/branch1 [PATCH] branch t/branch1
126 0 t/branch2 [PATCH] branch t/branch2
127 0 t/branch3 [PATCH] branch t/branch3
128 0 t/branch4 [PATCH] branch t/branch4
129 0 t/branch5 [PATCH] branch t/branch5
130 0 t/primary [PATCH] branch t/primary
131 0 t/primary2 [PATCH] branch t/primary2
132 > t/secondary [PATCH] branch t/secondary
133 0 t/secondary2 [PATCH] branch t/secondary2
135 trim tg summary >actual &&
136 test_cmp actual expected &&
137 cat <<-EOT >expected &&
138 Topic Branch: t/primary (1/1 commit)
139 Subject: [PATCH] branch t/primary
140 Dependents: t/primary2
141 Base: 8e476c63c7ef4558
142 Depends: t/branch1
143 Up-to-date.
145 trim tg info -v t/primary >actual &&
146 test_cmp actual expected &&
147 cat <<-EOT >expected &&
148 Topic Branch: t/secondary (2/2 commits)
149 Subject: [PATCH] branch t/secondary
150 Dependents: t/secondary2
151 Base: 8f7ce5c9f088954c
152 Depends: t/branch2
153 Up-to-date.
155 trim tg info -v t/secondary >actual &&
156 test_cmp actual expected
159 test_expect_success LASTOK 'setup index and working tree' '
160 echo "From: $from" >.topmsg &&
161 echo "Subject: [PATCH] branch t/tertiary" >>.topmsg &&
162 echo t/branch3 >.topdeps &&
163 echo file3 >f3 &&
164 git rm f4 f5 &&
165 git add .topdeps .topmsg f3 &&
166 echo "From: $from" >.topmsg &&
167 echo "Subject: [PATCH] branch t/quaternary" >>.topmsg &&
168 echo t/branch4 >.topdeps &&
169 echo t/branch5 >>.topdeps &&
170 rm -f f3 &&
171 echo file4 >f4 &&
172 echo file5 >f5 &&
173 test_when_finished test_set_prereq SETUP
176 test_expect_success SETUP 'files' '
177 cat <<-EOT >expected &&
182 tg files >actual &&
183 test_cmp actual expected
186 test_expect_success SETUP 'files -i' '
187 cat <<-EOT >expected &&
190 tg files -i >actual &&
191 test_cmp actual expected
194 test_expect_success SETUP 'files -w' '
195 cat <<-EOT >expected &&
199 tg files -w >actual &&
200 test_cmp actual expected
203 # tg mail uses tg patch so test tg patch and follow up with tg mail
205 test_expect_success SETUP 'patch' '
206 cat <<-\EOT >expected &&
207 From: Te s t (Author) <test@example.net>
208 Subject: [PATCH] branch t/secondary
211 f3 | 0
212 f4 | 0
213 f5 | 0
214 3 files changed, 0 insertions(+), 0 deletions(-)
215 create mode 100644 f3
216 create mode 100644 f4
217 create mode 100644 f5
219 diff --git a/f3 b/f3
220 new file mode 100644
221 index 0000000000000000..e69de29bb2d1d643
222 diff --git a/f4 b/f4
223 new file mode 100644
224 index 0000000000000000..e69de29bb2d1d643
225 diff --git a/f5 b/f5
226 new file mode 100644
227 index 0000000000000000..e69de29bb2d1d643
230 tg: (8f7ce5c9f088954c..) t/secondary (depends on: t/branch2)
232 tg patch >actual &&
233 test_cmp actual expected
236 test_expect_success SETUP,LASTOK 'mail' '
237 PATH="$PWD/.git/dummy:$PATH" && export PATH &&
238 tg mail >actual &&
239 test_cmp actual expected
242 test_expect_success SETUP 'patch -i' '
243 cat <<-\EOT >expected &&
244 From: Te s t (Author) <test@example.net>
245 Subject: [PATCH] branch t/tertiary
248 f3 | 1 +
249 1 file changed, 1 insertion(+)
250 create mode 100644 f3
252 diff --git a/f3 b/f3
253 new file mode 100644
254 index 0000000000000000..7c8ac2f8d82a1eb5
255 --- /dev/null
256 +++ b/f3
257 @@ -0,0 +1 @@
258 +file3
261 tg: (8f7ce5c9f088954c..) t/secondary (depends on: t/branch3)
263 tg patch -i >actual &&
264 test_cmp actual expected
267 test_expect_success SETUP,LASTOK 'mail -i' '
268 PATH="$PWD/.git/dummy:$PATH" && export PATH &&
269 tg mail -i >actual &&
270 test_cmp actual expected
273 test_expect_success SETUP 'patch -w' '
274 cat <<-\EOT >expected &&
275 From: Te s t (Author) <test@example.net>
276 Subject: [PATCH] branch t/quaternary
279 f4 | 1 +
280 f5 | 1 +
281 2 files changed, 2 insertions(+)
282 create mode 100644 f4
283 create mode 100644 f5
285 diff --git a/f4 b/f4
286 new file mode 100644
287 index 0000000000000000..bfd6a6583f9a9ac5
288 --- /dev/null
289 +++ b/f4
290 @@ -0,0 +1 @@
291 +file4
292 diff --git a/f5 b/f5
293 new file mode 100644
294 index 0000000000000000..4806cb9df135782b
295 --- /dev/null
296 +++ b/f5
297 @@ -0,0 +1 @@
298 +file5
301 tg: (8f7ce5c9f088954c..) t/secondary (depends on: t/branch4 t/branch5)
303 tg patch -w >actual &&
304 test_cmp actual expected
307 test_expect_success SETUP,LASTOK 'mail -w' '
308 PATH="$PWD/.git/dummy:$PATH" && export PATH &&
309 tg mail -w >actual &&
310 test_cmp actual expected
313 test_expect_success SETUP 'prev' '
314 echo t/branch2 >expected &&
315 tg prev >actual &&
316 test_cmp actual expected
319 test_expect_success SETUP 'prev -i' '
320 echo t/branch3 >expected &&
321 tg prev -i >actual &&
322 test_cmp actual expected
325 test_expect_success SETUP 'prev -w' '
326 echo t/branch5 >expected &&
327 tg prev -w >actual &&
328 test_cmp actual expected &&
329 echo t/branch4 >expected &&
330 tg prev -w -n 2 >actual &&
331 test_cmp actual expected
334 test_expect_success SETUP 'next' '
335 echo t/secondary2 >expected &&
336 tg next >actual &&
337 test_cmp actual expected
340 test_expect_success SETUP 'next -i' '
341 echo t/secondary >expected &&
342 tg next -i t/branch3 >actual &&
343 test_cmp actual expected &&
344 >expected &&
345 tg next -i t/branch2 >actual &&
346 test_cmp actual expected &&
347 tg next -i t/branch4 >actual &&
348 test_cmp actual expected &&
349 tg next -i t/branch5 >actual &&
350 test_cmp actual expected
353 test_expect_success SETUP 'next -w' '
354 echo t/branch5 >expected &&
355 tg next -w t/branch4 >actual &&
356 test_cmp actual expected &&
357 echo t/secondary >expected &&
358 tg next -w t/branch5 >actual &&
359 test_cmp actual expected &&
360 >expected &&
361 tg next -w t/branch2 >actual &&
362 test_cmp actual expected &&
363 tg next -w t/branch3 >actual &&
364 test_cmp actual expected
367 test_expect_success SETUP 'summary --deps-only' '
368 cat <<-\EOT >expected &&
369 branch2
370 t/branch2
371 t/secondary
373 tg summary --deps-only >actual &&
374 test_cmp actual expected
377 test_expect_success SETUP 'summary --deps-only -i' '
378 cat <<-\EOT >expected &&
379 branch3
380 t/branch3
381 t/secondary
383 tg summary --deps-only -i >actual &&
384 test_cmp actual expected
387 test_expect_success SETUP 'summary --deps-only -w' '
388 cat <<-\EOT >expected &&
389 branch4
390 branch5
391 t/branch4
392 t/branch5
393 t/secondary
395 tg summary --deps-only -w >actual &&
396 test_cmp actual expected
399 test_expect_success SETUP 'summary --deps' '
400 cat <<-\EOT >expected &&
401 t/branch1 branch1
402 t/branch2 branch2
403 t/branch3 branch3
404 t/branch4 branch4
405 t/branch5 branch5
406 t/primary t/branch1
407 t/primary2 t/primary
408 t/secondary t/branch2
409 t/secondary2 t/secondary
411 tg summary --deps >actual &&
412 test_cmp actual expected
415 test_expect_success SETUP 'summary --deps -i' '
416 cat <<-\EOT >expected &&
417 t/branch1 branch1
418 t/branch2 branch2
419 t/branch3 branch3
420 t/branch4 branch4
421 t/branch5 branch5
422 t/primary t/branch1
423 t/primary2 t/primary
424 t/secondary t/branch3
425 t/secondary2 t/secondary
427 tg summary --deps -i >actual &&
428 test_cmp actual expected
431 test_expect_success SETUP 'summary --deps -w' '
432 cat <<-\EOT >expected &&
433 t/branch1 branch1
434 t/branch2 branch2
435 t/branch3 branch3
436 t/branch4 branch4
437 t/branch5 branch5
438 t/primary t/branch1
439 t/primary2 t/primary
440 t/secondary t/branch4
441 t/secondary t/branch5
442 t/secondary2 t/secondary
444 tg summary --deps -w >actual &&
445 test_cmp actual expected
448 test_expect_success SETUP 'summary --rdeps --heads' '
449 cat <<\EOT >expected &&
450 t/branch3
451 branch3
453 t/branch4
454 branch4
456 t/branch5
457 branch5
459 t/primary2
460 t/primary
461 t/branch1
462 branch1
464 t/secondary2
465 t/secondary
466 t/branch2
467 branch2
469 tg summary --rdeps --heads >actual &&
470 test_cmp actual expected
473 test_expect_success SETUP 'summary --rdeps --heads -i' '
474 cat <<\EOT >expected &&
475 t/branch2
476 branch2
478 t/branch4
479 branch4
481 t/branch5
482 branch5
484 t/primary2
485 t/primary
486 t/branch1
487 branch1
489 t/secondary2
490 t/secondary
491 t/branch3
492 branch3
494 tg summary --rdeps --heads -i >actual &&
495 test_cmp actual expected
498 test_expect_success SETUP 'summary --rdeps --heads -w' '
499 cat <<\EOT >expected &&
500 t/branch2
501 branch2
503 t/branch3
504 branch3
506 t/primary2
507 t/primary
508 t/branch1
509 branch1
511 t/secondary2
512 t/secondary
513 t/branch4
514 branch4
515 t/branch5
516 branch5
518 tg summary --rdeps --heads -w >actual &&
519 test_cmp actual expected
522 test_expect_success SETUP 'summary -vl' '
523 cat <<\EOT >expected &&
524 t/branch1 [PATCH] branch t/branch1
525 t/branch2 [PATCH] branch t/branch2
526 t/branch3 [PATCH] branch t/branch3
527 t/branch4 [PATCH] branch t/branch4
528 t/branch5 [PATCH] branch t/branch5
529 t/primary [PATCH] branch t/primary
530 t/primary2 [PATCH] branch t/primary2
531 t/secondary [PATCH] branch t/secondary
532 t/secondary2 [PATCH] branch t/secondary2
534 trim tg summary -vl >actual &&
535 test_cmp actual expected &&
536 trim tg summary -vvl >actual &&
537 test_cmp actual expected
540 test_expect_success SETUP 'summary -vl -i' '
541 cat <<\EOT >expected &&
542 t/branch1 [PATCH] branch t/branch1
543 t/branch2 [PATCH] branch t/branch2
544 t/branch3 [PATCH] branch t/branch3
545 t/branch4 [PATCH] branch t/branch4
546 t/branch5 [PATCH] branch t/branch5
547 t/primary [PATCH] branch t/primary
548 t/primary2 [PATCH] branch t/primary2
549 t/secondary [PATCH] branch t/tertiary
550 t/secondary2 [PATCH] branch t/secondary2
552 trim tg summary -vl -i >actual &&
553 test_cmp actual expected &&
554 trim tg summary -vvl -i >actual &&
555 test_cmp actual expected
558 test_expect_success SETUP 'summary -vl -w' '
559 cat <<\EOT >expected &&
560 t/branch1 [PATCH] branch t/branch1
561 t/branch2 [PATCH] branch t/branch2
562 t/branch3 [PATCH] branch t/branch3
563 t/branch4 [PATCH] branch t/branch4
564 t/branch5 [PATCH] branch t/branch5
565 t/primary [PATCH] branch t/primary
566 t/primary2 [PATCH] branch t/primary2
567 t/secondary [PATCH] branch t/quaternary
568 t/secondary2 [PATCH] branch t/secondary2
570 trim tg summary -vl -w >actual &&
571 test_cmp actual expected &&
572 trim tg summary -vvl -w >actual &&
573 test_cmp actual expected
576 test_expect_success SETUP 'summary @' '
577 cat <<\EOT >expected &&
578 0 t/branch2 [PATCH] branch t/branch2
579 > t/secondary [PATCH] branch t/secondary
580 0 t/secondary2 [PATCH] branch t/secondary2
582 trim tg summary @ >actual &&
583 test_cmp actual expected
586 test_expect_success SETUP 'summary -i @' '
587 cat <<\EOT >expected &&
588 0 * t/branch3 [PATCH] branch t/branch3
589 > D t/secondary [PATCH] branch t/tertiary
590 0 D t/secondary2 [PATCH] branch t/secondary2
592 trim tg summary -i @ >actual &&
593 test_cmp actual expected
596 test_expect_success SETUP 'summary -w @' '
597 cat <<\EOT >expected &&
598 0 * t/branch4 [PATCH] branch t/branch4
599 0 * t/branch5 [PATCH] branch t/branch5
600 > D t/secondary [PATCH] branch t/quaternary
601 0 D t/secondary2 [PATCH] branch t/secondary2
603 trim tg summary -w @ >actual &&
604 test_cmp actual expected
607 test_expect_success SETUP 'summary' '
608 cat <<\EOT >expected &&
609 0 t/branch1 [PATCH] branch t/branch1
610 0 t/branch2 [PATCH] branch t/branch2
611 0 t/branch3 [PATCH] branch t/branch3
612 0 t/branch4 [PATCH] branch t/branch4
613 0 t/branch5 [PATCH] branch t/branch5
614 0 t/primary [PATCH] branch t/primary
615 0 t/primary2 [PATCH] branch t/primary2
616 > t/secondary [PATCH] branch t/secondary
617 0 t/secondary2 [PATCH] branch t/secondary2
619 trim tg summary >actual &&
620 test_cmp actual expected
623 test_expect_success SETUP 'summary -i' '
624 cat <<\EOT >expected &&
625 0 t/branch1 [PATCH] branch t/branch1
626 0 t/branch2 [PATCH] branch t/branch2
627 0 * t/branch3 [PATCH] branch t/branch3
628 0 t/branch4 [PATCH] branch t/branch4
629 0 t/branch5 [PATCH] branch t/branch5
630 0 t/primary [PATCH] branch t/primary
631 0 t/primary2 [PATCH] branch t/primary2
632 > D t/secondary [PATCH] branch t/tertiary
633 0 D t/secondary2 [PATCH] branch t/secondary2
635 trim tg summary -i >actual &&
636 test_cmp actual expected
639 test_expect_success SETUP 'summary -w' '
640 cat <<\EOT >expected &&
641 0 t/branch1 [PATCH] branch t/branch1
642 0 t/branch2 [PATCH] branch t/branch2
643 0 t/branch3 [PATCH] branch t/branch3
644 0 * t/branch4 [PATCH] branch t/branch4
645 0 * t/branch5 [PATCH] branch t/branch5
646 0 t/primary [PATCH] branch t/primary
647 0 t/primary2 [PATCH] branch t/primary2
648 > D t/secondary [PATCH] branch t/quaternary
649 0 D t/secondary2 [PATCH] branch t/secondary2
651 trim tg summary -w >actual &&
652 test_cmp actual expected
655 test_done