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>

Matthieu Moy committed Jun 29, 2015 at 17:40 UTC 4a6ada32cb64b0eba8b6f995e4230f0c722fd580
1 file changed +17 -13
git-bisect.sh
+17 -13
@@ -78,6 +78,7 @@ bisect_start() {
78 bad_seen=0
79 eval=''
80 must_write_terms=0
81 + revs=''
82 if test "z$(git rev-parse --is-bare-repository)" != zfalse
83 then
84 mode=--no-checkout
@@ -102,24 +103,27 @@ bisect_start() {
103 die "$(eval_gettext "'\$arg' does not appear to be a valid revision")"
104 break
105 }
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"
107 shift
108 ;;
109 esac
110 done
111
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
127 #
128 # Verify HEAD.
129 #