bisect: sanity check on terms
[git/git.git] / git-bisect.sh
CommitLineData
8cc6a083 1#!/bin/sh
d025524d 2
243a60fb
CC
3USAGE='[help|start|bad|good|skip|next|reset|visualize|replay|log|run]'
4LONG_USAGE='git bisect help
6021be86 5 print this long help message.
4796e823 6git bisect start [--no-checkout] [<bad> [<good>...]] [--] [<pathspec>...]
6021be86 7 reset bisect state and start bisection.
38a47fd6 8git bisect bad [<rev>]
6021be86 9 mark <rev> a known-bad revision.
38a47fd6 10git bisect good [<rev>...]
6021be86 11 mark <rev>... known-good revisions.
5413812f 12git bisect skip [(<rev>|<range>)...]
6021be86 13 mark <rev>... untestable revisions.
38a47fd6 14git bisect next
6021be86 15 find next bisection to test and check it out.
6b87ce23 16git bisect reset [<commit>]
6021be86 17 finish bisection search and go back to commit.
38a47fd6 18git bisect visualize
6021be86 19 show bisect status in gitk.
38a47fd6 20git bisect replay <logfile>
6021be86 21 replay bisection log.
38a47fd6 22git bisect log
6021be86 23 show bisect log.
38a47fd6 24git bisect run <cmd>...
6021be86 25 use <cmd>... to automatically bisect.
243a60fb
CC
26
27Please use "git help bisect" to get the full man page.'
d025524d 28
8f321a39 29OPTIONS_SPEC=
ae2b0f15 30. git-sh-setup
dcf9c2e5 31. git-sh-i18n
8cc6a083 32
ce32660e
JS
33_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
34_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
43f9d9f3
AD
35TERM_BAD=bad
36TERM_GOOD=good
ce32660e 37
4796e823
JS
38bisect_head()
39{
40 if test -f "$GIT_DIR/BISECT_HEAD"
41 then
42 echo BISECT_HEAD
43 else
44 echo HEAD
45 fi
46}
47
8cc6a083 48bisect_autostart() {
823ea121 49 test -s "$GIT_DIR/BISECT_START" || {
3145b1a2 50 gettextln "You need to start by \"git bisect start\"" >&2
8cc6a083
LT
51 if test -t 0
52 then
04de0996
ÆAB
53 # TRANSLATORS: Make sure to include [Y] and [n] in your
54 # translation. The program will only accept English input
55 # at this point.
6021be86 56 gettext "Do you want me to do it for you [Y/n]? " >&2
8cc6a083
LT
57 read yesno
58 case "$yesno" in
59 [Nn]*)
60 exit ;;
61 esac
62 bisect_start
63 else
64 exit 1
65 fi
66 }
67}
68
69bisect_start() {
4764f464
JS
70 #
71 # Check for one bad and then some good revisions.
72 #
73 has_double_dash=0
74 for arg; do
6021be86 75 case "$arg" in --) has_double_dash=1; break ;; esac
4764f464
JS
76 done
77 orig_args=$(git rev-parse --sq-quote "$@")
78 bad_seen=0
79 eval=''
cb46d630 80 must_write_terms=0
4a6ada32 81 revs=''
24c51280
JS
82 if test "z$(git rev-parse --is-bare-repository)" != zfalse
83 then
84 mode=--no-checkout
85 else
86 mode=''
87 fi
4764f464 88 while [ $# -gt 0 ]; do
6021be86
JS
89 arg="$1"
90 case "$arg" in
91 --)
92 shift
93 break
4764f464 94 ;;
6021be86
JS
95 --no-checkout)
96 mode=--no-checkout
97 shift ;;
98 --*)
99 die "$(eval_gettext "unrecognised option: '\$arg'")" ;;
100 *)
101 rev=$(git rev-parse -q --verify "$arg^{commit}") || {
43b8ff4b
JH
102 test $has_double_dash -eq 1 &&
103 die "$(eval_gettext "'\$arg' does not appear to be a valid revision")"
104 break
6021be86 105 }
4a6ada32 106 revs="$revs $rev"
6021be86
JS
107 shift
108 ;;
4764f464 109 esac
4764f464
JS
110 done
111
4a6ada32
MM
112 for rev in $revs
113 do
114 # The user ran "git bisect start <sha1>
115 # <sha1>", hence did not explicitly specify
116 # the terms, but we are already starting to
117 # set references named with the default terms,
118 # and won't be able to change afterwards.
119 must_write_terms=1
120
121 case $bad_seen in
122 0) state=$TERM_BAD ; bad_seen=1 ;;
123 *) state=$TERM_GOOD ;;
124 esac
125 eval="$eval bisect_write '$state' '$rev' 'nolog' &&"
126 done
8cc6a083 127 #
634f2464 128 # Verify HEAD.
8cc6a083 129 #
48949a18 130 head=$(GIT_DIR="$GIT_DIR" git symbolic-ref -q HEAD) ||
ce32660e 131 head=$(GIT_DIR="$GIT_DIR" git rev-parse --verify HEAD) ||
9570fc1e 132 die "$(gettext "Bad HEAD - I need a HEAD")"
634f2464 133
ee831f7d 134 #
634f2464 135 # Check if we are bisecting.
ee831f7d 136 #
d3e54c88 137 start_head=''
634f2464
CC
138 if test -s "$GIT_DIR/BISECT_START"
139 then
140 # Reset to the rev from where we started.
9d0cd91c 141 start_head=$(cat "$GIT_DIR/BISECT_START")
4796e823
JS
142 if test "z$mode" != "z--no-checkout"
143 then
1acf1171 144 git checkout "$start_head" -- ||
9c9b4f2f 145 die "$(eval_gettext "Checking out '\$start_head' failed. Try 'git bisect reset <valid-branch>'.")"
4796e823 146 fi
634f2464
CC
147 else
148 # Get rev from where we start.
149 case "$head" in
150 refs/heads/*|$_x40)
151 # This error message should only be triggered by
152 # cogito usage, and cogito users should understand
153 # it relates to cg-seek.
154 [ -s "$GIT_DIR/head-name" ] &&
382d20e3 155 die "$(gettext "won't bisect on cg-seek'ed tree")"
634f2464
CC
156 start_head="${head#refs/heads/}"
157 ;;
158 *)
9570fc1e 159 die "$(gettext "Bad HEAD - strange symbolic ref")"
634f2464
CC
160 ;;
161 esac
162 fi
8cc6a083
LT
163
164 #
634f2464 165 # Get rid of any old bisect state.
8cc6a083 166 #
823ea121 167 bisect_clean_state || exit
38a47fd6 168
ba963de8
CC
169 #
170 # Change state.
171 # In case of mistaken revs or checkout error, or signals received,
172 # "bisect_auto_next" below may exit or misbehave.
173 # We have to trap this to be able to clean up using
174 # "bisect_clean_state".
175 #
176 trap 'bisect_clean_state' 0
177 trap 'exit 255' 1 2 3 15
178
179 #
180 # Write new start state.
181 #
4796e823
JS
182 echo "$start_head" >"$GIT_DIR/BISECT_START" && {
183 test "z$mode" != "z--no-checkout" ||
184 git update-ref --no-deref BISECT_HEAD "$start_head"
185 } &&
de52f5a8 186 git rev-parse --sq-quote "$@" >"$GIT_DIR/BISECT_NAMES" &&
6ba7acff 187 eval "$eval true" &&
cb46d630
AD
188 if test $must_write_terms -eq 1
189 then
190 write_terms "$TERM_BAD" "$TERM_GOOD"
191 fi &&
6c98c054 192 echo "git bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG" || exit
ba963de8
CC
193 #
194 # Check if we can proceed to the next bisect state.
195 #
38a47fd6 196 bisect_auto_next
ba963de8
CC
197
198 trap '-' 0
8cc6a083
LT
199}
200
55624f9a
CC
201bisect_write() {
202 state="$1"
203 rev="$2"
737c74ee 204 nolog="$3"
55624f9a 205 case "$state" in
43f9d9f3
AD
206 "$TERM_BAD")
207 tag="$state" ;;
208 "$TERM_GOOD"|skip)
209 tag="$state"-"$rev" ;;
210 *)
211 die "$(eval_gettext "Bad bisect_write argument: \$state")" ;;
55624f9a 212 esac
ba963de8 213 git update-ref "refs/bisect/$tag" "$rev" || exit
f454cdc4 214 echo "# $state: $(git show-branch $rev)" >>"$GIT_DIR/BISECT_LOG"
6c98c054 215 test -n "$nolog" || echo "git bisect $state $rev" >>"$GIT_DIR/BISECT_LOG"
55624f9a
CC
216}
217
c9c4e2d5
CC
218is_expected_rev() {
219 test -f "$GIT_DIR/BISECT_EXPECTED_REV" &&
220 test "$1" = $(cat "$GIT_DIR/BISECT_EXPECTED_REV")
221}
222
c9c4e2d5
CC
223check_expected_revs() {
224 for _rev in "$@"; do
eef12a9a
JS
225 if ! is_expected_rev "$_rev"
226 then
c9c4e2d5
CC
227 rm -f "$GIT_DIR/BISECT_ANCESTORS_OK"
228 rm -f "$GIT_DIR/BISECT_EXPECTED_REV"
229 return
230 fi
231 done
232}
233
ee2314f5 234bisect_skip() {
6021be86 235 all=''
ee2314f5
CC
236 for arg in "$@"
237 do
6021be86
JS
238 case "$arg" in
239 *..*)
240 revs=$(git rev-list "$arg") || die "$(eval_gettext "Bad rev input: \$arg")" ;;
241 *)
242 revs=$(git rev-parse --sq-quote "$arg") ;;
243 esac
244 all="$all $revs"
245 done
246 eval bisect_state 'skip' $all
ee2314f5
CC
247}
248
155fc795 249bisect_state() {
8cc6a083 250 bisect_autostart
155fc795 251 state=$1
cb46d630 252 check_and_set_terms $state
155fc795
CC
253 case "$#,$state" in
254 0,*)
9570fc1e 255 die "$(gettext "Please call 'bisect_state' with at least one argument.")" ;;
43f9d9f3 256 1,"$TERM_BAD"|1,"$TERM_GOOD"|1,skip)
4796e823
JS
257 rev=$(git rev-parse --verify $(bisect_head)) ||
258 die "$(gettext "Bad rev input: $(bisect_head)")"
c9c4e2d5
CC
259 bisect_write "$state" "$rev"
260 check_expected_revs "$rev" ;;
43f9d9f3 261 2,"$TERM_BAD"|*,"$TERM_GOOD"|*,skip)
155fc795 262 shift
6bc02d56 263 hash_list=''
e3389075 264 for rev in "$@"
155fc795 265 do
a179a303 266 sha=$(git rev-parse --verify "$rev^{commit}") ||
15eaa049 267 die "$(eval_gettext "Bad rev input: \$rev")"
6bc02d56 268 hash_list="$hash_list $sha"
d3e54c88 269 done
6bc02d56
CC
270 for rev in $hash_list
271 do
272 bisect_write "$state" "$rev"
273 done
274 check_expected_revs $hash_list ;;
43f9d9f3
AD
275 *,"$TERM_BAD")
276 die "$(eval_gettext "'git bisect \$TERM_BAD' can take only one argument.")" ;;
cc9f24d0
JH
277 *)
278 usage ;;
8cc6a083 279 esac
97e1c51e
CC
280 bisect_auto_next
281}
282
8cc6a083 283bisect_next_check() {
0a5280a9 284 missing_good= missing_bad=
43f9d9f3
AD
285 git show-ref -q --verify refs/bisect/$TERM_BAD || missing_bad=t
286 test -n "$(git for-each-ref "refs/bisect/$TERM_GOOD-*")" || missing_good=t
6fecf191 287
0a5280a9
JH
288 case "$missing_good,$missing_bad,$1" in
289 ,,*)
43f9d9f3 290 : have both $TERM_GOOD and $TERM_BAD - ok
0a5280a9
JH
291 ;;
292 *,)
293 # do not have both but not asked to fail - just report.
294 false
295 ;;
43f9d9f3 296 t,,"$TERM_GOOD")
0a5280a9
JH
297 # have bad but not good. we could bisect although
298 # this is less optimum.
43f9d9f3 299 eval_gettextln "Warning: bisecting only with a \$TERM_BAD commit." >&2
0a5280a9
JH
300 if test -t 0
301 then
04de0996
ÆAB
302 # TRANSLATORS: Make sure to include [Y] and [n] in your
303 # translation. The program will only accept English input
304 # at this point.
305 gettext "Are you sure [Y/n]? " >&2
e5d3afd7
FM
306 read yesno
307 case "$yesno" in [Nn]*) exit 1 ;; esac
0a5280a9 308 fi
43f9d9f3 309 : bisect without $TERM_GOOD...
0a5280a9 310 ;;
8cc6a083 311 *)
cb46d630
AD
312 bad_syn=$(bisect_voc bad)
313 good_syn=$(bisect_voc good)
be508d3a
ÆAB
314 if test -s "$GIT_DIR/BISECT_START"
315 then
cb46d630
AD
316
317 eval_gettextln "You need to give me at least one \$bad_syn and one \$good_syn revision.
318(You can use \"git bisect \$bad_syn\" and \"git bisect \$good_syn\" for that.)" >&2
be508d3a 319 else
cb46d630
AD
320 eval_gettextln "You need to start by \"git bisect start\".
321You then need to give me at least one \$good_syn and one \$bad_syn revision.
322(You can use \"git bisect \$bad_syn\" and \"git bisect \$good_syn\" for that.)" >&2
be508d3a 323 fi
0a5280a9 324 exit 1 ;;
8cc6a083
LT
325 esac
326}
327
328bisect_auto_next() {
434d036f 329 bisect_next_check && bisect_next || :
8cc6a083
LT
330}
331
332bisect_next() {
8fe26f44 333 case "$#" in 0) ;; *) usage ;; esac
8cc6a083 334 bisect_autostart
43f9d9f3 335 bisect_next_check $TERM_GOOD
0a5280a9 336
0871984d 337 # Perform all bisection computation, display and checkout
4796e823 338 git bisect--helper --next-all $(test -f "$GIT_DIR/BISECT_HEAD" && echo --no-checkout)
5a1d31c7 339 res=$?
0a5280a9 340
6021be86 341 # Check if we should exit because bisection is finished
a7f8b8ac
TH
342 if test $res -eq 10
343 then
43f9d9f3 344 bad_rev=$(git show-ref --hash --verify refs/bisect/$TERM_BAD)
a7f8b8ac 345 bad_commit=$(git show-branch $bad_rev)
43f9d9f3 346 echo "# first $TERM_BAD commit: $bad_commit" >>"$GIT_DIR/BISECT_LOG"
a7f8b8ac 347 exit 0
f989cac9
TH
348 elif test $res -eq 2
349 then
350 echo "# only skipped commits left to test" >>"$GIT_DIR/BISECT_LOG"
43f9d9f3
AD
351 good_revs=$(git for-each-ref --format="%(objectname)" "refs/bisect/$TERM_GOOD-*")
352 for skipped in $(git rev-list refs/bisect/$TERM_BAD --not $good_revs)
f989cac9
TH
353 do
354 skipped_commit=$(git show-branch $skipped)
43f9d9f3 355 echo "# possible first $TERM_BAD commit: $skipped_commit" >>"$GIT_DIR/BISECT_LOG"
f989cac9
TH
356 done
357 exit $res
a7f8b8ac 358 fi
0a5280a9 359
5a1d31c7
CC
360 # Check for an error in the bisection process
361 test $res -ne 0 && exit $res
362
363 return 0
8cc6a083
LT
364}
365
cc9f24d0
JH
366bisect_visualize() {
367 bisect_next_check fail
235997c9
JH
368
369 if test $# = 0
370 then
c4e4644e 371 if test -n "${DISPLAY+set}${SESSIONNAME+set}${MSYSTEM+set}${SECURITYSESSIONID+set}" &&
43b8ff4b 372 type gitk >/dev/null 2>&1
eef12a9a 373 then
c4e4644e
JK
374 set gitk
375 else
376 set git log
377 fi
235997c9
JH
378 else
379 case "$1" in
380 git*|tig) ;;
381 -*) set git log "$@" ;;
382 *) set git "$@" ;;
383 esac
384 fi
385
fc13aa3d 386 eval '"$@"' --bisect -- $(cat "$GIT_DIR/BISECT_NAMES")
cc9f24d0
JH
387}
388
8cc6a083 389bisect_reset() {
823ea121 390 test -s "$GIT_DIR/BISECT_START" || {
3145b1a2 391 gettextln "We are not bisecting."
fce0499f
CC
392 return
393 }
8cc6a083 394 case "$#" in
823ea121 395 0) branch=$(cat "$GIT_DIR/BISECT_START") ;;
305a233c 396 1) git rev-parse --quiet --verify "$1^{commit}" >/dev/null || {
6021be86
JS
397 invalid="$1"
398 die "$(eval_gettext "'\$invalid' is not a valid commit")"
399 }
400 branch="$1" ;;
8fe26f44 401 *)
6021be86 402 usage ;;
8cc6a083 403 esac
43b8ff4b
JH
404
405 if ! test -f "$GIT_DIR/BISECT_HEAD" && ! git checkout "$branch" --
4796e823 406 then
43b8ff4b 407 die "$(eval_gettext "Could not check out original HEAD '\$branch'.
15eaa049 408Try 'git bisect reset <commit>'.")"
3bb8cf88 409 fi
4796e823 410 bisect_clean_state
e204de28
JH
411}
412
38a47fd6 413bisect_clean_state() {
947a604b 414 # There may be some refs packed during bisection.
634f2464 415 git for-each-ref --format='%(refname) %(objectname)' refs/bisect/\* |
947a604b
CC
416 while read ref hash
417 do
823ea121 418 git update-ref -d $ref $hash || exit
947a604b 419 done
c9c4e2d5
CC
420 rm -f "$GIT_DIR/BISECT_EXPECTED_REV" &&
421 rm -f "$GIT_DIR/BISECT_ANCESTORS_OK" &&
823ea121
CC
422 rm -f "$GIT_DIR/BISECT_LOG" &&
423 rm -f "$GIT_DIR/BISECT_NAMES" &&
424 rm -f "$GIT_DIR/BISECT_RUN" &&
cb46d630 425 rm -f "$GIT_DIR/BISECT_TERMS" &&
9d0cd91c 426 # Cleanup head-name if it got left by an old version of git-bisect
823ea121 427 rm -f "$GIT_DIR/head-name" &&
4796e823
JS
428 git update-ref -d --no-deref BISECT_HEAD &&
429 # clean up BISECT_START last
823ea121 430 rm -f "$GIT_DIR/BISECT_START"
38a47fd6
CC
431}
432
e204de28 433bisect_replay () {
55a9fc80
ÆAB
434 file="$1"
435 test "$#" -eq 1 || die "$(gettext "No logfile given")"
436 test -r "$file" || die "$(eval_gettext "cannot read \$file for replaying")"
e204de28 437 bisect_reset
6c98c054 438 while read git bisect command rev
e204de28 439 do
c82af12a 440 test "$git $bisect" = "git bisect" || test "$git" = "git-bisect" || continue
eef12a9a
JS
441 if test "$git" = "git-bisect"
442 then
6c98c054
MV
443 rev="$command"
444 command="$bisect"
445 fi
cb46d630
AD
446 get_terms
447 check_and_set_terms "$command"
e204de28
JH
448 case "$command" in
449 start)
e9a45d75 450 cmd="bisect_start $rev"
737c74ee 451 eval "$cmd" ;;
cb46d630 452 "$TERM_GOOD"|"$TERM_BAD"|skip)
737c74ee 453 bisect_write "$command" "$rev" ;;
e204de28 454 *)
9570fc1e 455 die "$(gettext "?? what are you talking about?")" ;;
e204de28 456 esac
55a9fc80 457 done <"$file"
e204de28 458 bisect_auto_next
8cc6a083
LT
459}
460
a17c4101 461bisect_run () {
6021be86
JS
462 bisect_next_check fail
463
464 while true
465 do
466 command="$@"
3145b1a2 467 eval_gettextln "running \$command"
6021be86
JS
468 "$@"
469 res=$?
470
471 # Check for really bad run error.
eef12a9a
JS
472 if [ $res -lt 0 -o $res -ge 128 ]
473 then
3145b1a2
JS
474 eval_gettextln "bisect run failed:
475exit code \$res from '\$command' is < 0 or >= 128" >&2
6021be86
JS
476 exit $res
477 fi
478
479 # Find current state depending on run success or failure.
480 # A special exit code of 125 means cannot test.
eef12a9a
JS
481 if [ $res -eq 125 ]
482 then
6021be86 483 state='skip'
eef12a9a
JS
484 elif [ $res -gt 0 ]
485 then
43f9d9f3 486 state="$TERM_BAD"
6021be86 487 else
43f9d9f3 488 state="$TERM_GOOD"
6021be86
JS
489 fi
490
491 # We have to use a subshell because "bisect_state" can exit.
305a233c 492 ( bisect_state $state >"$GIT_DIR/BISECT_RUN" )
6021be86
JS
493 res=$?
494
495 cat "$GIT_DIR/BISECT_RUN"
496
43f9d9f3 497 if sane_grep "first $TERM_BAD commit could be any of" "$GIT_DIR/BISECT_RUN" \
305a233c 498 >/dev/null
eef12a9a 499 then
3145b1a2 500 gettextln "bisect run cannot continue any more" >&2
6021be86
JS
501 exit $res
502 fi
503
eef12a9a
JS
504 if [ $res -ne 0 ]
505 then
3145b1a2
JS
506 eval_gettextln "bisect run failed:
507'bisect_state \$state' exited with error code \$res" >&2
6021be86
JS
508 exit $res
509 fi
a17c4101 510
43f9d9f3 511 if sane_grep "is the first $TERM_BAD commit" "$GIT_DIR/BISECT_RUN" >/dev/null
eef12a9a 512 then
3145b1a2 513 gettextln "bisect run success"
6021be86
JS
514 exit 0;
515 fi
a17c4101 516
6021be86 517 done
a17c4101
CC
518}
519
412ff738 520bisect_log () {
9570fc1e 521 test -s "$GIT_DIR/BISECT_LOG" || die "$(gettext "We are not bisecting.")"
412ff738
SG
522 cat "$GIT_DIR/BISECT_LOG"
523}
a17c4101 524
cb46d630
AD
525get_terms () {
526 if test -s "$GIT_DIR/BISECT_TERMS"
527 then
528 {
529 read TERM_BAD
530 read TERM_GOOD
531 } <"$GIT_DIR/BISECT_TERMS"
532 fi
533}
534
535write_terms () {
536 TERM_BAD=$1
537 TERM_GOOD=$2
fe67687b
MM
538 if test "$TERM_BAD" = "$TERM_GOOD"
539 then
540 die "$(gettext "please use two different terms")"
541 fi
542 check_term_format "$TERM_BAD" bad
543 check_term_format "$TERM_GOOD" good
cb46d630
AD
544 printf '%s\n%s\n' "$TERM_BAD" "$TERM_GOOD" >"$GIT_DIR/BISECT_TERMS"
545}
546
fe67687b
MM
547check_term_format () {
548 term=$1
549 git check-ref-format refs/bisect/"$term" ||
550 die "$(eval_gettext "'\$term' is not a valid term")"
551 case "$term" in
552 help|start|terms|skip|next|reset|visualize|replay|log|run)
553 die "$(eval_gettext "can't use the builtin command '\$term' as a term")"
554 ;;
555 bad|new)
556 if test "$2" != bad
557 then
558 # In theory, nothing prevents swapping
559 # completely good and bad, but this situation
560 # could be confusing and hasn't been tested
561 # enough. Forbid it for now.
562 die "$(eval_gettext "can't change the meaning of term '\$term'")"
563 fi
564 ;;
565 good|old)
566 if test "$2" != good
567 then
568 die "$(eval_gettext "can't change the meaning of term '\$term'")"
569 fi
570 ;;
571 esac
572}
573
cb46d630
AD
574check_and_set_terms () {
575 cmd="$1"
576 case "$cmd" in
577 skip|start|terms) ;;
578 *)
579 if test -s "$GIT_DIR/BISECT_TERMS" && test "$cmd" != "$TERM_BAD" && test "$cmd" != "$TERM_GOOD"
580 then
581 die "$(eval_gettext "Invalid command: you're currently in a \$TERM_BAD/\$TERM_GOOD bisect.")"
582 fi
583 case "$cmd" in
584 bad|good)
585 if ! test -s "$GIT_DIR/BISECT_TERMS"
586 then
587 write_terms bad good
588 fi
589 ;;
590 esac ;;
591 esac
592}
593
594bisect_voc () {
595 case "$1" in
596 bad) echo "bad" ;;
597 good) echo "good" ;;
598 esac
599}
600
8cc6a083
LT
601case "$#" in
6020)
6021be86 603 usage ;;
8cc6a083 604*)
6021be86 605 cmd="$1"
cb46d630 606 get_terms
6021be86
JS
607 shift
608 case "$cmd" in
609 help)
610 git bisect -h ;;
611 start)
612 bisect_start "$@" ;;
cb46d630 613 bad|good|"$TERM_BAD"|"$TERM_GOOD")
6021be86
JS
614 bisect_state "$cmd" "$@" ;;
615 skip)
616 bisect_skip "$@" ;;
617 next)
618 # Not sure we want "next" at the UI level anymore.
619 bisect_next "$@" ;;
620 visualize|view)
621 bisect_visualize "$@" ;;
622 reset)
623 bisect_reset "$@" ;;
624 replay)
625 bisect_replay "$@" ;;
626 log)
627 bisect_log ;;
628 run)
629 bisect_run "$@" ;;
630 *)
631 usage ;;
632 esac
8cc6a083 633esac