bisect: fix left over "BISECT_START" file when starting with junk rev
Before this patch, when using for example: $ git bisect start <stuff1> <stuff2> with <stuff1> or <stuff2> that cannot be parsed as a revision, we could leave a ".git/BISECT_START" file, from a previous "git bisect start", alone. This patch makes sure that it does not happen by removing the "BISECT_START" file in "bisect_clean_state" and then always writing it again at the end of "bisect_start". Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
May 23, 2008 at 00:38 UTC
9d0cd91c4e497192e89177847d1511acea5793cd
2 files changed
+8
-10
git-bisect.sh
+7
-9
@@ -81,8 +81,8 @@ bisect_start() {
81
start_head=''
82
case "$head" in
83
refs/heads/bisect)
84
- branch=`cat "$GIT_DIR/BISECT_START"`
85
- git checkout $branch || exit
84
+ start_head=$(cat "$GIT_DIR/BISECT_START")
85
+ git checkout "$start_head" || exit
86
;;
87
refs/heads/*|$_x40)
88
# This error message should only be triggered by cogito usage,
@@ -134,7 +134,7 @@ bisect_start() {
134
done
135
136
sq "$@" >"$GIT_DIR/BISECT_NAMES"
137
- test -n "$start_head" && echo "$start_head" >"$GIT_DIR/BISECT_START"
137
+ echo "$start_head" >"$GIT_DIR/BISECT_START"
138
eval "$eval"
139
echo "git-bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG"
140
bisect_auto_next
@@ -392,12 +392,7 @@ bisect_reset() {
392
*)
393
usage ;;
394
esac
395
- if git checkout "$branch"; then
396
- # Cleanup head-name if it got left by an old version of git-bisect
397
- rm -f "$GIT_DIR/head-name"
398
- rm -f "$GIT_DIR/BISECT_START"
399
- bisect_clean_state
400
- fi
395
+ git checkout "$branch" && bisect_clean_state
396
}
397
398
bisect_clean_state() {
@@ -407,9 +402,12 @@ bisect_clean_state() {
402
do
403
git update-ref -d $ref $hash
404
done
405
+ rm -f "$GIT_DIR/BISECT_START"
406
rm -f "$GIT_DIR/BISECT_LOG"
407
rm -f "$GIT_DIR/BISECT_NAMES"
408
rm -f "$GIT_DIR/BISECT_RUN"
409
+ # Cleanup head-name if it got left by an old version of git-bisect
410
+ rm -f "$GIT_DIR/head-name"
411
}
412
413
bisect_replay () {
t/t6030-bisect-porcelain.sh
+1
-1
@@ -138,7 +138,7 @@ test_expect_success 'bisect start: back in good branch' '
138
grep "* other" branch.output > /dev/null
139
'
140
141
-test_expect_failure 'bisect start: no ".git/BISECT_START" if junk rev' '
141
+test_expect_success 'bisect start: no ".git/BISECT_START" if junk rev' '
142
git bisect start $HASH4 $HASH1 -- &&
143
git bisect good &&
144
test_must_fail git bisect start $HASH4 foo -- &&