]> git.ipfire.org Git - thirdparty/git.git/commitdiff
bisect: add 'git bisect terms' to view the current terms
authorMatthieu Moy <Matthieu.Moy@imag.fr>
Mon, 29 Jun 2015 15:40:34 +0000 (17:40 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 3 Aug 2015 18:42:42 +0000 (11:42 -0700)
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-bisect.txt
git-bisect.sh
t/t6030-bisect-porcelain.sh

index abaf462273c1ad367474058d4abc630155e99a37..4dd62958098f4b3ce3a9759b41e96b187f732a4f 100644 (file)
@@ -19,6 +19,7 @@ on the subcommand:
  git bisect start [--no-checkout] [<bad> [<good>...]] [--] [<paths>...]
  git bisect (bad|new) [<rev>]
  git bisect (good|old) [<rev>...]
+ git bisect terms [--term-good | --term-bad]
  git bisect skip [(<rev>|<range>)...]
  git bisect reset [<commit>]
  git bisect visualize
@@ -157,6 +158,15 @@ git bisect new [<rev>...]
 
 to indicate that it was after.
 
+To get a reminder of the currently used terms, use
+
+------------------------------------------------
+git bisect terms
+------------------------------------------------
+
+You can get just the old (respectively new) term with `git bisect term
+--term-old` or `git bisect term --term-good`.
+
 Bisect visualize
 ~~~~~~~~~~~~~~~~
 
index d78b043b11dabea1b3bf82002a305b427578e681..89255a333f4fe39675bf249376c328a497671371 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-USAGE='[help|start|bad|good|new|old|skip|next|reset|visualize|replay|log|run]'
+USAGE='[help|start|bad|good|new|old|terms|skip|next|reset|visualize|replay|log|run]'
 LONG_USAGE='git bisect help
        print this long help message.
 git bisect start [--no-checkout] [<bad> [<good>...]] [--] [<pathspec>...]
@@ -11,6 +11,8 @@ git bisect (bad|new) [<rev>]
 git bisect (good|old) [<rev>...]
        mark <rev>... known-good revisions/
                revisions before change in a given property.
+git bisect terms [--term-good | --term-bad]
+       show the terms used for old and new commits (default: bad, good)
 git bisect skip [(<rev>|<range>)...]
        mark <rev>... untestable revisions.
 git bisect next
@@ -453,6 +455,8 @@ bisect_replay () {
                        eval "$cmd" ;;
                "$TERM_GOOD"|"$TERM_BAD"|skip)
                        bisect_write "$command" "$rev" ;;
+               terms)
+                       bisect_terms $rev ;;
                *)
                        die "$(gettext "?? what are you talking about?")" ;;
                esac
@@ -606,6 +610,37 @@ bisect_voc () {
        esac
 }
 
+bisect_terms () {
+       get_terms
+       if ! test -s "$GIT_DIR/BISECT_TERMS"
+       then
+               die "$(gettext "no terms defined")"
+       fi
+       case "$#" in
+       0)
+               gettextln "Your current terms are $TERM_GOOD for the old state
+and $TERM_BAD for the new state."
+               ;;
+       1)
+               arg=$1
+               case "$arg" in
+                       --term-good|--term-old)
+                               printf '%s\n' "$TERM_GOOD"
+                               ;;
+                       --term-bad|--term-new)
+                               printf '%s\n' "$TERM_BAD"
+                               ;;
+                       *)
+                               die "$(eval_gettext "invalid argument \$arg for 'git bisect terms'.
+Supported options are: --term-good|--term-old and --term-bad|--term-new.")"
+                               ;;
+               esac
+               ;;
+       *)
+               usage ;;
+       esac
+}
+
 case "$#" in
 0)
        usage ;;
@@ -635,6 +670,8 @@ case "$#" in
                bisect_log ;;
        run)
                bisect_run "$@" ;;
+       terms)
+               bisect_terms "$@" ;;
        *)
                usage ;;
        esac
index 983c5033c9c6e0e2206fbfd16285df4f747ba5ed..93934886508a09c08b2899b801f65ff1af69633e 100755 (executable)
@@ -797,4 +797,24 @@ test_expect_success 'bisect cannot mix old/new and good/bad' '
        test_must_fail git bisect old $HASH1
 '
 
+test_expect_success 'bisect terms needs 0 or 1 argument' '
+       git bisect reset &&
+       test_must_fail git bisect terms only-one &&
+       test_must_fail git bisect terms 1 2 &&
+       test_must_fail git bisect terms 2>actual &&
+       echo "no terms defined" >expected &&
+       test_cmp expected actual
+'
+
+test_expect_success 'bisect terms shows good/bad after start' '
+       git bisect reset &&
+       git bisect start HEAD $HASH1 &&
+       git bisect terms --term-good >actual &&
+       echo good >expected &&
+       test_cmp expected actual &&
+       git bisect terms --term-bad >actual &&
+       echo bad >expected &&
+       test_cmp expected actual
+'
+
 test_done