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>
This commit is contained in:
Christian Couder 2014-12-25 19:25:32 +01:00 committed by Junio C Hamano
parent c2e8e4b9da
commit 6bc02d5627

View file

@ -237,15 +237,18 @@ bisect_state() {
check_expected_revs "$rev" ;; check_expected_revs "$rev" ;;
2,bad|*,good|*,skip) 2,bad|*,good|*,skip)
shift shift
eval='' hash_list=''
for rev in "$@" for rev in "$@"
do do
sha=$(git rev-parse --verify "$rev^{commit}") || sha=$(git rev-parse --verify "$rev^{commit}") ||
die "$(eval_gettext "Bad rev input: \$rev")" die "$(eval_gettext "Bad rev input: \$rev")"
eval="$eval bisect_write '$state' '$sha'; " hash_list="$hash_list $sha"
done done
eval "$eval" for rev in $hash_list
check_expected_revs "$@" ;; do
bisect_write "$state" "$rev"
done
check_expected_revs $hash_list ;;
*,bad) *,bad)
die "$(gettext "'git bisect bad' can take only one argument.")" ;; die "$(gettext "'git bisect bad' can take only one argument.")" ;;
*) *)