@matheusbsbs / matheus-bagliano / commits / 810255fd12
Fork 0

Properly git-bisect reset after bisecting from non-master head

git-bisect reset without an argument would return to master even if the bisecting started at a non-master branch. This patch makes it save the original branch name to .git/head-name and restore it afterwards. This is also compatible with Cogito and cg-seek, so cg-status will show that we are seeked on the bisect branch and cg-reset will properly restore the original branch. git-bisect start will refuse to work if it is not on a bisect but .git/head-name exists; this is to protect against conflicts with other seeking tools. Signed-off-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Junio C Hamano <junkio@cox.net>

Petr Baudis committed Feb 12, 2006 at 17:06 UTC 810255fd12536d296597a0366f514bf65c2e10f6
1 file changed +14 -3
git-bisect.sh
+14 -3
@@ -49,9 +49,16 @@ bisect_start() {
49 die "Bad HEAD - I need a symbolic ref"
50 case "$head" in
51 refs/heads/bisect*)
52 - git checkout master || exit
52 + if [ -s "$GIT_DIR/head-name" ]; then
53 + branch=`cat "$GIT_DIR/head-name"`
54 + else
55 + branch=master
56 + fi
57 + git checkout $branch || exit
58 ;;
59 refs/heads/*)
60 + [ -s "$GIT_DIR/head-name" ] && die "won't bisect on seeked tree"
61 + echo "$head" | sed 's#^refs/heads/##' >"$GIT_DIR/head-name"
62 ;;
63 *)
64 die "Bad HEAD - strange symbolic ref"
@@ -159,7 +166,11 @@ bisect_visualize() {
166
167 bisect_reset() {
168 case "$#" in
162 - 0) branch=master ;;
169 + 0) if [ -s "$GIT_DIR/head-name" ]; then
170 + branch=`cat "$GIT_DIR/head-name"`
171 + else
172 + branch=master
173 + fi ;;
174 1) test -f "$GIT_DIR/refs/heads/$1" || {
175 echo >&2 "$1 does not seem to be a valid branch"
176 exit 1
@@ -170,7 +181,7 @@ bisect_reset() {
181 esac
182 git checkout "$branch" &&
183 rm -fr "$GIT_DIR/refs/bisect"
173 - rm -f "$GIT_DIR/refs/heads/bisect"
184 + rm -f "$GIT_DIR/refs/heads/bisect" "$GIT_DIR/head-name"
185 rm -f "$GIT_DIR/BISECT_LOG"
186 }
187