77
orig_args=$(git rev-parse --sq-quote "$@")
78
bad_seen=0
79
eval=''
80
+ must_write_terms=0
81
if test "z$(git rev-parse --is-bare-repository)" != zfalse
82
then
83
mode=--no-checkout
102
die "$(eval_gettext "'\$arg' does not appear to be a valid revision")"
103
break
104
}
105
+
106
+ # The user ran "git bisect start <sha1>
107
+ # <sha1>", hence did not explicitly specify
108
+ # the terms, but we are already starting to
109
+ # set references named with the default terms,
110
+ # and won't be able to change afterwards.
111
+ must_write_terms=1
112
+
113
case $bad_seen in
114
0) state=$TERM_BAD ; bad_seen=1 ;;
115
*) state=$TERM_GOOD ;;
181
} &&
182
git rev-parse --sq-quote "$@" >"$GIT_DIR/BISECT_NAMES" &&
183
eval "$eval true" &&
184
+ if test $must_write_terms -eq 1
185
+ then
186
+ write_terms "$TERM_BAD" "$TERM_GOOD"
187
+ fi &&
188
echo "git bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG" || exit
189
#
190
# Check if we can proceed to the next bisect state.
245
bisect_state() {
246
bisect_autostart
247
state=$1
248
+ check_and_set_terms $state
249
case "$#,$state" in
250
0,*)
251
die "$(gettext "Please call 'bisect_state' with at least one argument.")" ;;
305
: bisect without $TERM_GOOD...
306
;;
307
*)
294
-
308
+ bad_syn=$(bisect_voc bad)
309
+ good_syn=$(bisect_voc good)
310
if test -s "$GIT_DIR/BISECT_START"
311
then
297
- gettextln "You need to give me at least one good and one bad revision.
298
-(You can use \"git bisect bad\" and \"git bisect good\" for that.)" >&2
312
+
313
+ eval_gettextln "You need to give me at least one \$bad_syn and one \$good_syn revision.
314
+(You can use \"git bisect \$bad_syn\" and \"git bisect \$good_syn\" for that.)" >&2
315
else
300
- gettextln "You need to start by \"git bisect start\".
301
-You then need to give me at least one good and one bad revision.
302
-(You can use \"git bisect bad\" and \"git bisect good\" for that.)" >&2
316
+ eval_gettextln "You need to start by \"git bisect start\".
317
+You then need to give me at least one \$good_syn and one \$bad_syn revision.
318
+(You can use \"git bisect \$bad_syn\" and \"git bisect \$good_syn\" for that.)" >&2
319
fi
320
exit 1 ;;
321
esac
418
rm -f "$GIT_DIR/BISECT_LOG" &&
419
rm -f "$GIT_DIR/BISECT_NAMES" &&
420
rm -f "$GIT_DIR/BISECT_RUN" &&
421
+ rm -f "$GIT_DIR/BISECT_TERMS" &&
422
# Cleanup head-name if it got left by an old version of git-bisect
423
rm -f "$GIT_DIR/head-name" &&
424
git update-ref -d --no-deref BISECT_HEAD &&
439
rev="$command"
440
command="$bisect"
441
fi
442
+ get_terms
443
+ check_and_set_terms "$command"
444
case "$command" in
445
start)
446
cmd="bisect_start $rev"
447
eval "$cmd" ;;
429
- $TERM_GOOD|$TERM_BAD|skip)
448
+ "$TERM_GOOD"|"$TERM_BAD"|skip)
449
bisect_write "$command" "$rev" ;;
450
*)
451
die "$(gettext "?? what are you talking about?")" ;;
518
cat "$GIT_DIR/BISECT_LOG"
519
}
520
521
+get_terms () {
522
+ if test -s "$GIT_DIR/BISECT_TERMS"
523
+ then
524
+ {
525
+ read TERM_BAD
526
+ read TERM_GOOD
527
+ } <"$GIT_DIR/BISECT_TERMS"
528
+ fi
529
+}
530
+
531
+write_terms () {
532
+ TERM_BAD=$1
533
+ TERM_GOOD=$2
534
+ printf '%s\n%s\n' "$TERM_BAD" "$TERM_GOOD" >"$GIT_DIR/BISECT_TERMS"
535
+}
536
+
537
+check_and_set_terms () {
538
+ cmd="$1"
539
+ case "$cmd" in
540
+ skip|start|terms) ;;
541
+ *)
542
+ if test -s "$GIT_DIR/BISECT_TERMS" && test "$cmd" != "$TERM_BAD" && test "$cmd" != "$TERM_GOOD"
543
+ then
544
+ die "$(eval_gettext "Invalid command: you're currently in a \$TERM_BAD/\$TERM_GOOD bisect.")"
545
+ fi
546
+ case "$cmd" in
547
+ bad|good)
548
+ if ! test -s "$GIT_DIR/BISECT_TERMS"
549
+ then
550
+ write_terms bad good
551
+ fi
552
+ ;;
553
+ esac ;;
554
+ esac
555
+}
556
+
557
+bisect_voc () {
558
+ case "$1" in
559
+ bad) echo "bad" ;;
560
+ good) echo "good" ;;
561
+ esac
562
+}
563
+
564
case "$#" in
565
0)
566
usage ;;
567
*)
568
cmd="$1"
569
+ get_terms
570
shift
571
case "$cmd" in
572
help)
573
git bisect -h ;;
574
start)
575
bisect_start "$@" ;;
513
- bad|good)
576
+ bad|good|"$TERM_BAD"|"$TERM_GOOD")
577
bisect_state "$cmd" "$@" ;;
578
skip)
579
bisect_skip "$@" ;;