bisect: parse revs before passing them to check_expected_revs()

When running for example "git bisect bad HEAD" or "git bisect good master", the parameter passed to "git bisect (bad|good)" has to be parsed into a commit hash before checking if it is the expected commit or not. We could do that in is_expected_rev() or in check_expected_revs(), but it is already done in bisect_state(). Let's just store the hash values that result from this parsing, and then reuse them after all the parsing is done. This way we can also use a for loop over these values to call bisect_write() on them, instead of using eval. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Dec 25, 2014 at 19:25 UTC 6bc02d5627358f6a264c5dbb159b5a9aeb44ebf4
1 file changed +7 -4
git-bisect.sh
+7 -4
@@ -237,15 +237,18 @@ bisect_state() {
237 check_expected_revs "$rev" ;;
238 2,bad|*,good|*,skip)
239 shift
240 - eval=''
240 + hash_list=''
241 for rev in "$@"
242 do
243 sha=$(git rev-parse --verify "$rev^{commit}") ||
244 die "$(eval_gettext "Bad rev input: \$rev")"
245 - eval="$eval bisect_write '$state' '$sha'; "
245 + hash_list="$hash_list $sha"
246 done
247 - eval "$eval"
248 - check_expected_revs "$@" ;;
247 + for rev in $hash_list
248 + do
249 + bisect_write "$state" "$rev"
250 + done
251 + check_expected_revs $hash_list ;;
252 *,bad)
253 die "$(gettext "'git bisect bad' can take only one argument.")" ;;
254 *)