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>
This commit is contained in:

committed by
Junio C Hamano

parent
d3aca58562
commit
9d0cd91c4e
@ -81,8 +81,8 @@ bisect_start() {
|
|||||||
start_head=''
|
start_head=''
|
||||||
case "$head" in
|
case "$head" in
|
||||||
refs/heads/bisect)
|
refs/heads/bisect)
|
||||||
branch=`cat "$GIT_DIR/BISECT_START"`
|
start_head=$(cat "$GIT_DIR/BISECT_START")
|
||||||
git checkout $branch || exit
|
git checkout "$start_head" || exit
|
||||||
;;
|
;;
|
||||||
refs/heads/*|$_x40)
|
refs/heads/*|$_x40)
|
||||||
# This error message should only be triggered by cogito usage,
|
# This error message should only be triggered by cogito usage,
|
||||||
@ -134,7 +134,7 @@ bisect_start() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
sq "$@" >"$GIT_DIR/BISECT_NAMES"
|
sq "$@" >"$GIT_DIR/BISECT_NAMES"
|
||||||
test -n "$start_head" && echo "$start_head" >"$GIT_DIR/BISECT_START"
|
echo "$start_head" >"$GIT_DIR/BISECT_START"
|
||||||
eval "$eval"
|
eval "$eval"
|
||||||
echo "git-bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG"
|
echo "git-bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG"
|
||||||
bisect_auto_next
|
bisect_auto_next
|
||||||
@ -392,12 +392,7 @@ bisect_reset() {
|
|||||||
*)
|
*)
|
||||||
usage ;;
|
usage ;;
|
||||||
esac
|
esac
|
||||||
if git checkout "$branch"; then
|
git checkout "$branch" && bisect_clean_state
|
||||||
# Cleanup head-name if it got left by an old version of git-bisect
|
|
||||||
rm -f "$GIT_DIR/head-name"
|
|
||||||
rm -f "$GIT_DIR/BISECT_START"
|
|
||||||
bisect_clean_state
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bisect_clean_state() {
|
bisect_clean_state() {
|
||||||
@ -407,9 +402,12 @@ bisect_clean_state() {
|
|||||||
do
|
do
|
||||||
git update-ref -d $ref $hash
|
git update-ref -d $ref $hash
|
||||||
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
|
||||||
|
rm -f "$GIT_DIR/head-name"
|
||||||
}
|
}
|
||||||
|
|
||||||
bisect_replay () {
|
bisect_replay () {
|
||||||
|
@ -138,7 +138,7 @@ test_expect_success 'bisect start: back in good branch' '
|
|||||||
grep "* other" branch.output > /dev/null
|
grep "* other" branch.output > /dev/null
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_failure 'bisect start: no ".git/BISECT_START" if junk rev' '
|
test_expect_success 'bisect start: no ".git/BISECT_START" if junk rev' '
|
||||||
git bisect start $HASH4 $HASH1 -- &&
|
git bisect start $HASH4 $HASH1 -- &&
|
||||||
git bisect good &&
|
git bisect good &&
|
||||||
test_must_fail git bisect start $HASH4 foo -- &&
|
test_must_fail git bisect start $HASH4 foo -- &&
|
||||||
|
Reference in New Issue
Block a user