@matheusbsbs / matheus-bagliano / commits / 0f497e75f0
Fork 0

Eliminate confusing "won't bisect on seeked tree" failure

This error message is very confusing---it doesn't tell the user anything about how to fix the situation. And the actual fix for the situation ("git bisect reset") does a checkout of a potentially random branch, (compared to what the user wants to be on for the bisect she is starting). The simplest way to eliminate the confusion is to just make "git bisect start" do the cleanup itself. There's no significant loss of safety here since we already have a general safety in the form of the reflog. Note: We preserve the warning for any cogito users. We do this by switching from .git/head-name to .git/BISECT_START for the extra state, (which is a more descriptive name anyway). Signed-off-by: Carl Worth <cworth@cworth.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Carl Worth committed Feb 23, 2008 at 17:14 UTC 0f497e75f05cdf0c0c1278eaba898cda6f118d71
2 files changed +10 -6
git-bisect.sh
+9 -5
@@ -67,16 +67,18 @@ bisect_start() {
67 die "Bad HEAD - I need a HEAD"
68 case "$head" in
69 refs/heads/bisect)
70 - if [ -s "$GIT_DIR/head-name" ]; then
71 - branch=`cat "$GIT_DIR/head-name"`
70 + if [ -s "$GIT_DIR/BISECT_START" ]; then
71 + branch=`cat "$GIT_DIR/BISECT_START"`
72 else
73 branch=master
74 fi
75 git checkout $branch || exit
76 ;;
77 refs/heads/*|$_x40)
78 + # This error message should only be triggered by cogito usage,
79 + # and cogito users should understand it relates to cg-seek.
80 [ -s "$GIT_DIR/head-name" ] && die "won't bisect on seeked tree"
79 - echo "${head#refs/heads/}" >"$GIT_DIR/head-name"
81 + echo "${head#refs/heads/}" >"$GIT_DIR/BISECT_START"
82 ;;
83 *)
84 die "Bad HEAD - strange symbolic ref"
@@ -353,8 +355,8 @@ bisect_reset() {
355 return
356 }
357 case "$#" in
356 - 0) if [ -s "$GIT_DIR/head-name" ]; then
357 - branch=`cat "$GIT_DIR/head-name"`
358 + 0) if [ -s "$GIT_DIR/BISECT_START" ]; then
359 + branch=`cat "$GIT_DIR/BISECT_START"`
360 else
361 branch=master
362 fi ;;
@@ -365,7 +367,9 @@ bisect_reset() {
367 usage ;;
368 esac
369 if git checkout "$branch"; then
370 + # Cleanup head-name if it got left by an old version of git-bisect
371 rm -f "$GIT_DIR/head-name"
372 + rm -f "$GIT_DIR/BISECT_START"
373 bisect_clean_state
374 fi
375 }
t/t6030-bisect-porcelain.sh
+1 -1
@@ -260,7 +260,7 @@ test_expect_success 'bisect starting with a detached HEAD' '
260 git checkout master^ &&
261 HEAD=$(git rev-parse --verify HEAD) &&
262 git bisect start &&
263 - test $HEAD = $(cat .git/head-name) &&
263 + test $HEAD = $(cat .git/BISECT_START) &&
264 git bisect reset &&
265 test $HEAD = $(git rev-parse --verify HEAD)
266