Skip to content

Commit 4a6ada3

Browse files
moygitster
authored andcommitted
bisect: don't mix option parsing and non-trivial code
As-is, the revisions that appear on the command-line are processed in order. This would mix badly with code that changes the configuration (e.g. change $TERM_GOOD and $TERM_BAD) while processing the options. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent cb46d63 commit 4a6ada3

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

git-bisect.sh

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ bisect_start() {
7878
bad_seen=0
7979
eval=''
8080
must_write_terms=0
81+
revs=''
8182
if test "z$(git rev-parse --is-bare-repository)" != zfalse
8283
then
8384
mode=--no-checkout
@@ -102,24 +103,27 @@ bisect_start() {
102103
die "$(eval_gettext "'\$arg' does not appear to be a valid revision")"
103104
break
104105
}
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 ;;
116-
esac
117-
eval="$eval bisect_write '$state' '$rev' 'nolog' &&"
106+
revs="$revs $rev"
118107
shift
119108
;;
120109
esac
121110
done
122111

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
123127
#
124128
# Verify HEAD.
125129
#

0 commit comments

Comments
 (0)