Skip to content

Commit 21b55e3

Browse files
moygitster
authored andcommitted
bisect: add 'git bisect terms' to view the current terms
Signed-off-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 21e5cfd commit 21b55e3

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed

Documentation/git-bisect.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ on the subcommand:
1919
git bisect start [--no-checkout] [<bad> [<good>...]] [--] [<paths>...]
2020
git bisect (bad|new) [<rev>]
2121
git bisect (good|old) [<rev>...]
22+
git bisect terms [--term-good | --term-bad]
2223
git bisect skip [(<rev>|<range>)...]
2324
git bisect reset [<commit>]
2425
git bisect visualize
@@ -157,6 +158,15 @@ git bisect new [<rev>...]
157158

158159
to indicate that it was after.
159160

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+
160170
Bisect visualize
161171
~~~~~~~~~~~~~~~~
162172

git-bisect.sh

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

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]'
44
LONG_USAGE='git bisect help
55
print this long help message.
66
git bisect start [--no-checkout] [<bad> [<good>...]] [--] [<pathspec>...]
@@ -11,6 +11,8 @@ git bisect (bad|new) [<rev>]
1111
git bisect (good|old) [<rev>...]
1212
mark <rev>... known-good revisions/
1313
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)
1416
git bisect skip [(<rev>|<range>)...]
1517
mark <rev>... untestable revisions.
1618
git bisect next
@@ -453,6 +455,8 @@ bisect_replay () {
453455
eval "$cmd" ;;
454456
"$TERM_GOOD"|"$TERM_BAD"|skip)
455457
bisect_write "$command" "$rev" ;;
458+
terms)
459+
bisect_terms $rev ;;
456460
*)
457461
die "$(gettext "?? what are you talking about?")" ;;
458462
esac
@@ -606,6 +610,37 @@ bisect_voc () {
606610
esac
607611
}
608612

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+
609644
case "$#" in
610645
0)
611646
usage ;;
@@ -635,6 +670,8 @@ case "$#" in
635670
bisect_log ;;
636671
run)
637672
bisect_run "$@" ;;
673+
terms)
674+
bisect_terms "$@" ;;
638675
*)
639676
usage ;;
640677
esac

t/t6030-bisect-porcelain.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,4 +797,24 @@ test_expect_success 'bisect cannot mix old/new and good/bad' '
797797
test_must_fail git bisect old $HASH1
798798
'
799799

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+
800820
test_done

0 commit comments

Comments
 (0)