bisect: use "$GIT_DIR/BISECT_START" to check if we are bisecting

It seems simpler and safer to use the BISECT_START file everywhere
to decide if we are bisecting or not, instead of using it in some
places and BISECT_NAMES in other places.

In commit 6459c7c678 (Nov 18 2007,
Bisect: use "$GIT_DIR/BISECT_NAMES" to check if we are bisecting.),
we decided to use BISECT_NAMES but code changed a lot and we now
have to check BISECT_START first in the "bisect_start" function
anyway.

This patch also makes things a little bit safer by creating
the BISECT_START file first and deleting it last, and also by
adding checks in "bisect_clean_state".

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Christian Couder 2008-05-28 18:57:02 +02:00 committed by Junio C Hamano
parent efb98b4453
commit 823ea1211c
1 changed files with 13 additions and 16 deletions

View File

@ -44,7 +44,7 @@ sq() {
} }


bisect_autostart() { bisect_autostart() {
test -f "$GIT_DIR/BISECT_NAMES" || { test -s "$GIT_DIR/BISECT_START" || {
echo >&2 'You need to start by "git bisect start"' echo >&2 'You need to start by "git bisect start"'
if test -t 0 if test -t 0
then then
@ -98,7 +98,7 @@ bisect_start() {
# #
# Get rid of any old bisect state. # Get rid of any old bisect state.
# #
bisect_clean_state bisect_clean_state || exit


# #
# Check for one bad and then some good revisions. # Check for one bad and then some good revisions.
@ -146,8 +146,8 @@ bisect_start() {
# #
# Write new start state. # Write new start state.
# #
sq "$@" >"$GIT_DIR/BISECT_NAMES" &&
echo "$start_head" >"$GIT_DIR/BISECT_START" && echo "$start_head" >"$GIT_DIR/BISECT_START" &&
sq "$@" >"$GIT_DIR/BISECT_NAMES" &&
eval "$eval" && eval "$eval" &&
echo "git-bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG" || exit echo "git-bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG" || exit
# #
@ -226,7 +226,7 @@ bisect_next_check() {
;; ;;
*) *)
THEN='' THEN=''
test -f "$GIT_DIR/BISECT_NAMES" || { test -s "$GIT_DIR/BISECT_START" || {
echo >&2 'You need to start by "git bisect start".' echo >&2 'You need to start by "git bisect start".'
THEN='then ' THEN='then '
} }
@ -392,16 +392,12 @@ bisect_visualize() {
} }


bisect_reset() { bisect_reset() {
test -f "$GIT_DIR/BISECT_NAMES" || { test -s "$GIT_DIR/BISECT_START" || {
echo "We are not bisecting." echo "We are not bisecting."
return return
} }
case "$#" in case "$#" in
0) if [ -s "$GIT_DIR/BISECT_START" ]; then 0) branch=$(cat "$GIT_DIR/BISECT_START") ;;
branch=`cat "$GIT_DIR/BISECT_START"`
else
branch=master
fi ;;
1) git show-ref --verify --quiet -- "refs/heads/$1" || 1) git show-ref --verify --quiet -- "refs/heads/$1" ||
die "$1 does not seem to be a valid branch" die "$1 does not seem to be a valid branch"
branch="$1" ;; branch="$1" ;;
@ -416,14 +412,15 @@ bisect_clean_state() {
git for-each-ref --format='%(refname) %(objectname)' refs/bisect/\* | git for-each-ref --format='%(refname) %(objectname)' refs/bisect/\* |
while read ref hash while read ref hash
do do
git update-ref -d $ref $hash git update-ref -d $ref $hash || exit
done done
rm -f "$GIT_DIR/BISECT_START" rm -f "$GIT_DIR/BISECT_LOG" &&
rm -f "$GIT_DIR/BISECT_LOG" rm -f "$GIT_DIR/BISECT_NAMES" &&
rm -f "$GIT_DIR/BISECT_NAMES" rm -f "$GIT_DIR/BISECT_RUN" &&
rm -f "$GIT_DIR/BISECT_RUN"
# Cleanup head-name if it got left by an old version of git-bisect # Cleanup head-name if it got left by an old version of git-bisect
rm -f "$GIT_DIR/head-name" rm -f "$GIT_DIR/head-name" &&

rm -f "$GIT_DIR/BISECT_START"
} }


bisect_replay () { bisect_replay () {