bisect: allow starting with a detached HEAD
Instead of insisting on a symbolic ref, bisect now accepts detached HEADs, too. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Feb 10, 2008 at 13:59 UTC
ce32660edc2b83c6fdf550f6869e0b01e255dadb
2 files changed
+18
-2
git-bisect.sh
+6
-2
@@ -26,6 +26,9 @@ OPTIONS_SPEC=
26
. git-sh-setup
27
require_work_tree
28
29
+_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
30
+_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
31
+
32
sq() {
33
@@PERL@@ -e '
34
for (@ARGV) {
@@ -60,7 +63,8 @@ bisect_start() {
63
# top-of-line master first!
64
#
65
head=$(GIT_DIR="$GIT_DIR" git symbolic-ref HEAD) ||
63
- die "Bad HEAD - I need a symbolic ref"
66
+ head=$(GIT_DIR="$GIT_DIR" git rev-parse --verify HEAD) ||
67
+ die "Bad HEAD - I need a HEAD"
68
case "$head" in
69
refs/heads/bisect)
70
if [ -s "$GIT_DIR/head-name" ]; then
@@ -70,7 +74,7 @@ bisect_start() {
74
fi
75
git checkout $branch || exit
76
;;
73
- refs/heads/*)
77
+ refs/heads/*|$_x40)
78
[ -s "$GIT_DIR/head-name" ] && die "won't bisect on seeked tree"
79
echo "${head#refs/heads/}" >"$GIT_DIR/head-name"
80
;;
t/t6030-bisect-porcelain.sh
+12
@@ -254,6 +254,18 @@ test_expect_success 'bisect run & skip: find first bad' '
254
grep "$HASH6 is first bad commit" my_bisect_log.txt
255
'
256
257
+test_expect_success 'bisect starting with a detached HEAD' '
258
+
259
+ git bisect reset &&
260
+ git checkout master^ &&
261
+ HEAD=$(git rev-parse --verify HEAD) &&
262
+ git bisect start &&
263
+ test $HEAD = $(cat .git/head-name) &&
264
+ git bisect reset &&
265
+ test $HEAD = $(git rev-parse --verify HEAD)
266
+
267
+'
268
+
269
#
270
#
271
test_done