bisect: add 'git bisect terms' to view the current terms

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Matthieu Moy committed Jun 29, 2015 at 17:40 UTC 21b55e33695f47f3e2616d178ab1e06743bfef66
3 files changed +68 -1
Documentation/git-bisect.txt
+10
@@ -19,6 +19,7 @@ on the subcommand:
19 git bisect start [--no-checkout] [<bad> [<good>...]] [--] [<paths>...]
20 git bisect (bad|new) [<rev>]
21 git bisect (good|old) [<rev>...]
22 + git bisect terms [--term-good | --term-bad]
23 git bisect skip [(<rev>|<range>)...]
24 git bisect reset [<commit>]
25 git bisect visualize
@@ -157,6 +158,15 @@ git bisect new [<rev>...]
158
159 to indicate that it was after.
160
161 +To get a reminder of the currently used terms, use
162 +
163 +------------------------------------------------
164 +git bisect terms
165 +------------------------------------------------
166 +
167 +You can get just the old (respectively new) term with `git bisect term
168 +--term-old` or `git bisect term --term-good`.
169 +
170 Bisect visualize
171 ~~~~~~~~~~~~~~~~
172
git-bisect.sh
+38 -1
@@ -1,6 +1,6 @@
1 #!/bin/sh
2
3 -USAGE='[help|start|bad|good|new|old|skip|next|reset|visualize|replay|log|run]'
3 +USAGE='[help|start|bad|good|new|old|terms|skip|next|reset|visualize|replay|log|run]'
4 LONG_USAGE='git bisect help
5 print this long help message.
6 git bisect start [--no-checkout] [<bad> [<good>...]] [--] [<pathspec>...]
@@ -11,6 +11,8 @@ git bisect (bad|new) [<rev>]
11 git bisect (good|old) [<rev>...]
12 mark <rev>... known-good revisions/
13 revisions before change in a given property.
14 +git bisect terms [--term-good | --term-bad]
15 + show the terms used for old and new commits (default: bad, good)
16 git bisect skip [(<rev>|<range>)...]
17 mark <rev>... untestable revisions.
18 git bisect next
@@ -453,6 +455,8 @@ bisect_replay () {
455 eval "$cmd" ;;
456 "$TERM_GOOD"|"$TERM_BAD"|skip)
457 bisect_write "$command" "$rev" ;;
458 + terms)
459 + bisect_terms $rev ;;
460 *)
461 die "$(gettext "?? what are you talking about?")" ;;
462 esac
@@ -606,6 +610,37 @@ bisect_voc () {
610 esac
611 }
612
613 +bisect_terms () {
614 + get_terms
615 + if ! test -s "$GIT_DIR/BISECT_TERMS"
616 + then
617 + die "$(gettext "no terms defined")"
618 + fi
619 + case "$#" in
620 + 0)
621 + gettextln "Your current terms are $TERM_GOOD for the old state
622 +and $TERM_BAD for the new state."
623 + ;;
624 + 1)
625 + arg=$1
626 + case "$arg" in
627 + --term-good|--term-old)
628 + printf '%s\n' "$TERM_GOOD"
629 + ;;
630 + --term-bad|--term-new)
631 + printf '%s\n' "$TERM_BAD"
632 + ;;
633 + *)
634 + die "$(eval_gettext "invalid argument \$arg for 'git bisect terms'.
635 +Supported options are: --term-good|--term-old and --term-bad|--term-new.")"
636 + ;;
637 + esac
638 + ;;
639 + *)
640 + usage ;;
641 + esac
642 +}
643 +
644 case "$#" in
645 0)
646 usage ;;
@@ -635,6 +670,8 @@ case "$#" in
670 bisect_log ;;
671 run)
672 bisect_run "$@" ;;
673 + terms)
674 + bisect_terms "$@" ;;
675 *)
676 usage ;;
677 esac
t/t6030-bisect-porcelain.sh
+20
@@ -797,4 +797,24 @@ test_expect_success 'bisect cannot mix old/new and good/bad' '
797 test_must_fail git bisect old $HASH1
798 '
799
800 +test_expect_success 'bisect terms needs 0 or 1 argument' '
801 + git bisect reset &&
802 + test_must_fail git bisect terms only-one &&
803 + test_must_fail git bisect terms 1 2 &&
804 + test_must_fail git bisect terms 2>actual &&
805 + echo "no terms defined" >expected &&
806 + test_cmp expected actual
807 +'
808 +
809 +test_expect_success 'bisect terms shows good/bad after start' '
810 + git bisect reset &&
811 + git bisect start HEAD $HASH1 &&
812 + git bisect terms --term-good >actual &&
813 + echo good >expected &&
814 + test_cmp expected actual &&
815 + git bisect terms --term-bad >actual &&
816 + echo bad >expected &&
817 + test_cmp expected actual
818 +'
819 +
820 test_done