bisect: use "bisect--helper" and remove "filter_skipped" function
Use the new "git bisect--helper" builtin. It should be faster and safer instead of the old "filter_skipped" shell function. And it is a first step to move more shell code to C. As the output is a little bit different we have to change the code that interpret the results. But these changes improve code clarity. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
3b437b0dab
commit
23b5f18b50
@ -279,76 +279,13 @@ bisect_auto_next() {
|
|||||||
bisect_next_check && bisect_next || :
|
bisect_next_check && bisect_next || :
|
||||||
}
|
}
|
||||||
|
|
||||||
filter_skipped() {
|
eval_and_string_together() {
|
||||||
_eval="$1"
|
_eval="$1"
|
||||||
_skip="$2"
|
|
||||||
|
|
||||||
if [ -z "$_skip" ]; then
|
|
||||||
eval "$_eval" | {
|
|
||||||
while read line
|
|
||||||
do
|
|
||||||
echo "$line &&"
|
|
||||||
done
|
|
||||||
echo ':'
|
|
||||||
}
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Let's parse the output of:
|
|
||||||
# "git rev-list --bisect-vars --bisect-all ..."
|
|
||||||
eval "$_eval" | {
|
eval "$_eval" | {
|
||||||
VARS= FOUND= TRIED=
|
while read line
|
||||||
while read hash line
|
|
||||||
do
|
do
|
||||||
case "$VARS,$FOUND,$TRIED,$hash" in
|
echo "$line &&"
|
||||||
1,*,*,*)
|
|
||||||
# "bisect_foo=bar" read from rev-list output.
|
|
||||||
echo "$hash &&"
|
|
||||||
;;
|
|
||||||
,*,*,---*)
|
|
||||||
# Separator
|
|
||||||
;;
|
|
||||||
,,,bisect_rev*)
|
|
||||||
# We had nothing to search.
|
|
||||||
echo "bisect_rev= &&"
|
|
||||||
VARS=1
|
|
||||||
;;
|
|
||||||
,,*,bisect_rev*)
|
|
||||||
# We did not find a good bisect rev.
|
|
||||||
# This should happen only if the "bad"
|
|
||||||
# commit is also a "skip" commit.
|
|
||||||
echo "bisect_rev='$TRIED' &&"
|
|
||||||
VARS=1
|
|
||||||
;;
|
|
||||||
,,*,*)
|
|
||||||
# We are searching.
|
|
||||||
TRIED="${TRIED:+$TRIED|}$hash"
|
|
||||||
case "$_skip" in
|
|
||||||
*$hash*) ;;
|
|
||||||
*)
|
|
||||||
echo "bisect_rev=$hash &&"
|
|
||||||
echo "bisect_tried='$TRIED' &&"
|
|
||||||
FOUND=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
,1,*,bisect_rev*)
|
|
||||||
# We have already found a rev to be tested.
|
|
||||||
VARS=1
|
|
||||||
;;
|
|
||||||
,1,*,*)
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# Unexpected input
|
|
||||||
echo "die 'filter_skipped error'"
|
|
||||||
die "filter_skipped error " \
|
|
||||||
"VARS: '$VARS' " \
|
|
||||||
"FOUND: '$FOUND' " \
|
|
||||||
"TRIED: '$TRIED' " \
|
|
||||||
"hash: '$hash' " \
|
|
||||||
"line: '$line'"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
echo ':'
|
echo ':'
|
||||||
}
|
}
|
||||||
@ -356,10 +293,12 @@ filter_skipped() {
|
|||||||
|
|
||||||
exit_if_skipped_commits () {
|
exit_if_skipped_commits () {
|
||||||
_tried=$1
|
_tried=$1
|
||||||
if expr "$_tried" : ".*[|].*" > /dev/null ; then
|
_bad=$2
|
||||||
|
if test -n "$_tried" ; then
|
||||||
echo "There are only 'skip'ped commit left to test."
|
echo "There are only 'skip'ped commit left to test."
|
||||||
echo "The first bad commit could be any of:"
|
echo "The first bad commit could be any of:"
|
||||||
echo "$_tried" | tr '[|]' '[\012]'
|
echo "$_tried" | tr '[|]' '[\012]'
|
||||||
|
test -n "$_bad" && echo "$_bad"
|
||||||
echo "We cannot bisect more!"
|
echo "We cannot bisect more!"
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
@ -490,28 +429,24 @@ bisect_next() {
|
|||||||
test "$?" -eq "1" && return
|
test "$?" -eq "1" && return
|
||||||
|
|
||||||
# Get bisection information
|
# Get bisection information
|
||||||
BISECT_OPT=''
|
eval="git bisect--helper --next-vars" &&
|
||||||
test -n "$skip" && BISECT_OPT='--bisect-all'
|
eval=$(eval_and_string_together "$eval") &&
|
||||||
eval="git rev-list --bisect-vars $BISECT_OPT $good $bad --" &&
|
|
||||||
eval="$eval $(cat "$GIT_DIR/BISECT_NAMES")" &&
|
|
||||||
eval=$(filter_skipped "$eval" "$skip") &&
|
|
||||||
eval "$eval" || exit
|
eval "$eval" || exit
|
||||||
|
|
||||||
if [ -z "$bisect_rev" ]; then
|
if [ -z "$bisect_rev" ]; then
|
||||||
|
# We should exit here only if the "bad"
|
||||||
|
# commit is also a "skip" commit (see above).
|
||||||
|
exit_if_skipped_commits "$bisect_tried"
|
||||||
echo "$bad was both good and bad"
|
echo "$bad was both good and bad"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ "$bisect_rev" = "$bad" ]; then
|
if [ "$bisect_rev" = "$bad" ]; then
|
||||||
exit_if_skipped_commits "$bisect_tried"
|
exit_if_skipped_commits "$bisect_tried" "$bad"
|
||||||
echo "$bisect_rev is first bad commit"
|
echo "$bisect_rev is first bad commit"
|
||||||
git diff-tree --pretty $bisect_rev
|
git diff-tree --pretty $bisect_rev
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# We should exit here only if the "bad"
|
|
||||||
# commit is also a "skip" commit (see above).
|
|
||||||
exit_if_skipped_commits "$bisect_rev"
|
|
||||||
|
|
||||||
bisect_checkout "$bisect_rev" "$bisect_nr revisions left to test after this (roughly $bisect_steps steps)"
|
bisect_checkout "$bisect_rev" "$bisect_nr revisions left to test after this (roughly $bisect_steps steps)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user