@@ -77,6 +77,7 @@ bisect_start() {
77
77
orig_args=$( git rev-parse --sq-quote " $@ " )
78
78
bad_seen=0
79
79
eval=' '
80
+ must_write_terms=0
80
81
if test " z$( git rev-parse --is-bare-repository) " ! = zfalse
81
82
then
82
83
mode=--no-checkout
@@ -101,6 +102,14 @@ bisect_start() {
101
102
die " $( eval_gettext " '\$ arg' does not appear to be a valid revision" ) "
102
103
break
103
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
+
104
113
case $bad_seen in
105
114
0) state=$TERM_BAD ; bad_seen=1 ;;
106
115
* ) state=$TERM_GOOD ;;
@@ -172,6 +181,10 @@ bisect_start() {
172
181
} &&
173
182
git rev-parse --sq-quote " $@ " > " $GIT_DIR /BISECT_NAMES" &&
174
183
eval " $eval true" &&
184
+ if test $must_write_terms -eq 1
185
+ then
186
+ write_terms " $TERM_BAD " " $TERM_GOOD "
187
+ fi &&
175
188
echo " git bisect start$orig_args " >> " $GIT_DIR /BISECT_LOG" || exit
176
189
#
177
190
# Check if we can proceed to the next bisect state.
@@ -232,6 +245,7 @@ bisect_skip() {
232
245
bisect_state () {
233
246
bisect_autostart
234
247
state=$1
248
+ check_and_set_terms $state
235
249
case " $# ,$state " in
236
250
0,* )
237
251
die " $( gettext " Please call 'bisect_state' with at least one argument." ) " ;;
@@ -291,15 +305,17 @@ bisect_next_check() {
291
305
: bisect without $TERM_GOOD ...
292
306
;;
293
307
* )
294
-
308
+ bad_syn=$( bisect_voc bad)
309
+ good_syn=$( bisect_voc good)
295
310
if test -s " $GIT_DIR /BISECT_START"
296
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
299
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
303
319
fi
304
320
exit 1 ;;
305
321
esac
@@ -402,6 +418,7 @@ bisect_clean_state() {
402
418
rm -f " $GIT_DIR /BISECT_LOG" &&
403
419
rm -f " $GIT_DIR /BISECT_NAMES" &&
404
420
rm -f " $GIT_DIR /BISECT_RUN" &&
421
+ rm -f " $GIT_DIR /BISECT_TERMS" &&
405
422
# Cleanup head-name if it got left by an old version of git-bisect
406
423
rm -f " $GIT_DIR /head-name" &&
407
424
git update-ref -d --no-deref BISECT_HEAD &&
@@ -422,11 +439,13 @@ bisect_replay () {
422
439
rev=" $command "
423
440
command=" $bisect "
424
441
fi
442
+ get_terms
443
+ check_and_set_terms " $command "
425
444
case " $command " in
426
445
start)
427
446
cmd=" bisect_start $rev "
428
447
eval " $cmd " ;;
429
- $TERM_GOOD | $TERM_BAD |skip)
448
+ " $TERM_GOOD " | " $TERM_BAD " |skip)
430
449
bisect_write " $command " " $rev " ;;
431
450
* )
432
451
die " $( gettext " ?? what are you talking about?" ) " ;;
@@ -499,18 +518,62 @@ bisect_log () {
499
518
cat " $GIT_DIR /BISECT_LOG"
500
519
}
501
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
+
502
564
case " $# " in
503
565
0)
504
566
usage ;;
505
567
* )
506
568
cmd=" $1 "
569
+ get_terms
507
570
shift
508
571
case " $cmd " in
509
572
help)
510
573
git bisect -h ;;
511
574
start)
512
575
bisect_start " $@ " ;;
513
- bad|good)
576
+ bad|good| " $TERM_BAD " | " $TERM_GOOD " )
514
577
bisect_state " $cmd " " $@ " ;;
515
578
skip)
516
579
bisect_skip " $@ " ;;
0 commit comments