Bisect: refactor some logging into "bisect_write".
Also use "die" instead of "echo >&2 something ; exit 1". And simplify "bisect_replay". Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
55624f9af4
commit
737c74ee42
@ -106,12 +106,11 @@ bisect_start() {
|
|||||||
die "'$arg' does not appear to be a valid revision"
|
die "'$arg' does not appear to be a valid revision"
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if [ $bad_seen -eq 0 ]; then
|
case $bad_seen in
|
||||||
bad_seen=1
|
0) state='bad' ; bad_seen=1 ;;
|
||||||
bisect_write 'bad' "$rev"
|
*) state='good' ;;
|
||||||
else
|
esac
|
||||||
bisect_write 'good' "$rev"
|
bisect_write "$state" "$rev" 'nolog'
|
||||||
fi
|
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -125,6 +124,7 @@ bisect_start() {
|
|||||||
bisect_write() {
|
bisect_write() {
|
||||||
state="$1"
|
state="$1"
|
||||||
rev="$2"
|
rev="$2"
|
||||||
|
nolog="$3"
|
||||||
case "$state" in
|
case "$state" in
|
||||||
bad) tag="$state" ;;
|
bad) tag="$state" ;;
|
||||||
good|skip) tag="$state"-"$rev" ;;
|
good|skip) tag="$state"-"$rev" ;;
|
||||||
@ -132,6 +132,7 @@ bisect_write() {
|
|||||||
esac
|
esac
|
||||||
echo "$rev" >"$GIT_DIR/refs/bisect/$tag"
|
echo "$rev" >"$GIT_DIR/refs/bisect/$tag"
|
||||||
echo "# $state: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
|
echo "# $state: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
|
||||||
|
test -z "$nolog" && echo "git-bisect $state $rev" >>"$GIT_DIR/BISECT_LOG"
|
||||||
}
|
}
|
||||||
|
|
||||||
bisect_bad() {
|
bisect_bad() {
|
||||||
@ -145,7 +146,6 @@ bisect_bad() {
|
|||||||
usage ;;
|
usage ;;
|
||||||
esac || exit
|
esac || exit
|
||||||
bisect_write 'bad' "$rev"
|
bisect_write 'bad' "$rev"
|
||||||
echo "git-bisect bad $rev" >>"$GIT_DIR/BISECT_LOG"
|
|
||||||
bisect_auto_next
|
bisect_auto_next
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +160,6 @@ bisect_good() {
|
|||||||
do
|
do
|
||||||
rev=$(git rev-parse --verify "$rev^{commit}") || exit
|
rev=$(git rev-parse --verify "$rev^{commit}") || exit
|
||||||
bisect_write 'good' "$rev"
|
bisect_write 'good' "$rev"
|
||||||
echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG"
|
|
||||||
done
|
done
|
||||||
bisect_auto_next
|
bisect_auto_next
|
||||||
}
|
}
|
||||||
@ -176,7 +175,6 @@ bisect_skip() {
|
|||||||
do
|
do
|
||||||
rev=$(git rev-parse --verify "$rev^{commit}") || exit
|
rev=$(git rev-parse --verify "$rev^{commit}") || exit
|
||||||
bisect_write 'skip' "$rev"
|
bisect_write 'skip' "$rev"
|
||||||
echo "git-bisect skip $rev" >>"$GIT_DIR/BISECT_LOG"
|
|
||||||
done
|
done
|
||||||
bisect_auto_next
|
bisect_auto_next
|
||||||
}
|
}
|
||||||
@ -352,10 +350,8 @@ bisect_reset() {
|
|||||||
else
|
else
|
||||||
branch=master
|
branch=master
|
||||||
fi ;;
|
fi ;;
|
||||||
1) git show-ref --verify --quiet -- "refs/heads/$1" || {
|
1) git show-ref --verify --quiet -- "refs/heads/$1" ||
|
||||||
echo >&2 "$1 does not seem to be a valid branch"
|
die "$1 does not seem to be a valid branch"
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
branch="$1" ;;
|
branch="$1" ;;
|
||||||
*)
|
*)
|
||||||
usage ;;
|
usage ;;
|
||||||
@ -375,10 +371,7 @@ bisect_clean_state() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bisect_replay () {
|
bisect_replay () {
|
||||||
test -r "$1" || {
|
test -r "$1" || die "cannot read $1 for replaying"
|
||||||
echo >&2 "cannot read $1 for replaying"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
bisect_reset
|
bisect_reset
|
||||||
while read bisect command rev
|
while read bisect command rev
|
||||||
do
|
do
|
||||||
@ -386,23 +379,11 @@ bisect_replay () {
|
|||||||
case "$command" in
|
case "$command" in
|
||||||
start)
|
start)
|
||||||
cmd="bisect_start $rev"
|
cmd="bisect_start $rev"
|
||||||
eval "$cmd"
|
eval "$cmd" ;;
|
||||||
;;
|
good|bad|skip)
|
||||||
good)
|
bisect_write "$command" "$rev" ;;
|
||||||
bisect_write 'good' "$rev"
|
|
||||||
echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG"
|
|
||||||
;;
|
|
||||||
bad)
|
|
||||||
bisect_write 'bad' "$rev"
|
|
||||||
echo "git-bisect bad $rev" >>"$GIT_DIR/BISECT_LOG"
|
|
||||||
;;
|
|
||||||
skip)
|
|
||||||
bisect_write 'skip' "$rev"
|
|
||||||
echo "git-bisect skip $rev" >>"$GIT_DIR/BISECT_LOG"
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
echo >&2 "?? what are you talking about?"
|
die "?? what are you talking about?" ;;
|
||||||
exit 1 ;;
|
|
||||||
esac
|
esac
|
||||||
done <"$1"
|
done <"$1"
|
||||||
bisect_auto_next
|
bisect_auto_next
|
||||||
|
Reference in New Issue
Block a user