Merge branch 'cw/bisect'

* cw/bisect:
  Eliminate confusing "won't bisect on seeked tree" failure
This commit is contained in:
Junio C Hamano 2008-02-27 11:56:08 -08:00
commit 722f53ca2f
2 changed files with 10 additions and 6 deletions

View File

@ -67,16 +67,18 @@ bisect_start() {
die "Bad HEAD - I need a HEAD" die "Bad HEAD - I need a HEAD"
case "$head" in case "$head" in
refs/heads/bisect) refs/heads/bisect)
if [ -s "$GIT_DIR/head-name" ]; then if [ -s "$GIT_DIR/BISECT_START" ]; then
branch=`cat "$GIT_DIR/head-name"` branch=`cat "$GIT_DIR/BISECT_START"`
else else
branch=master branch=master
fi fi
git checkout $branch || exit git checkout $branch || exit
;; ;;
refs/heads/*|$_x40) refs/heads/*|$_x40)
# This error message should only be triggered by cogito usage,
# and cogito users should understand it relates to cg-seek.
[ -s "$GIT_DIR/head-name" ] && die "won't bisect on seeked tree" [ -s "$GIT_DIR/head-name" ] && die "won't bisect on seeked tree"
echo "${head#refs/heads/}" >"$GIT_DIR/head-name" echo "${head#refs/heads/}" >"$GIT_DIR/BISECT_START"
;; ;;
*) *)
die "Bad HEAD - strange symbolic ref" die "Bad HEAD - strange symbolic ref"
@ -353,8 +355,8 @@ bisect_reset() {
return return
} }
case "$#" in case "$#" in
0) if [ -s "$GIT_DIR/head-name" ]; then 0) if [ -s "$GIT_DIR/BISECT_START" ]; then
branch=`cat "$GIT_DIR/head-name"` branch=`cat "$GIT_DIR/BISECT_START"`
else else
branch=master branch=master
fi ;; fi ;;
@ -365,7 +367,9 @@ bisect_reset() {
usage ;; usage ;;
esac esac
if git checkout "$branch"; then if git checkout "$branch"; then
# 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_clean_state bisect_clean_state
fi fi
} }

View File

@ -260,7 +260,7 @@ test_expect_success 'bisect starting with a detached HEAD' '
git checkout master^ && git checkout master^ &&
HEAD=$(git rev-parse --verify HEAD) && HEAD=$(git rev-parse --verify HEAD) &&
git bisect start && git bisect start &&
test $HEAD = $(cat .git/head-name) && test $HEAD = $(cat .git/BISECT_START) &&
git bisect reset && git bisect reset &&
test $HEAD = $(git rev-parse --verify HEAD) test $HEAD = $(git rev-parse --verify HEAD)