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>
This commit is contained in:
parent
473d33168b
commit
ce32660edc
@ -26,6 +26,9 @@ OPTIONS_SPEC=
|
|||||||
. git-sh-setup
|
. git-sh-setup
|
||||||
require_work_tree
|
require_work_tree
|
||||||
|
|
||||||
|
_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
|
||||||
|
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
|
||||||
|
|
||||||
sq() {
|
sq() {
|
||||||
@@PERL@@ -e '
|
@@PERL@@ -e '
|
||||||
for (@ARGV) {
|
for (@ARGV) {
|
||||||
@ -60,7 +63,8 @@ bisect_start() {
|
|||||||
# top-of-line master first!
|
# top-of-line master first!
|
||||||
#
|
#
|
||||||
head=$(GIT_DIR="$GIT_DIR" git symbolic-ref HEAD) ||
|
head=$(GIT_DIR="$GIT_DIR" git symbolic-ref HEAD) ||
|
||||||
die "Bad HEAD - I need a symbolic ref"
|
head=$(GIT_DIR="$GIT_DIR" git rev-parse --verify 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/head-name" ]; then
|
||||||
@ -70,7 +74,7 @@ bisect_start() {
|
|||||||
fi
|
fi
|
||||||
git checkout $branch || exit
|
git checkout $branch || exit
|
||||||
;;
|
;;
|
||||||
refs/heads/*)
|
refs/heads/*|$_x40)
|
||||||
[ -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/head-name"
|
||||||
;;
|
;;
|
||||||
|
@ -254,6 +254,18 @@ test_expect_success 'bisect run & skip: find first bad' '
|
|||||||
grep "$HASH6 is first bad commit" my_bisect_log.txt
|
grep "$HASH6 is first bad commit" my_bisect_log.txt
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'bisect starting with a detached HEAD' '
|
||||||
|
|
||||||
|
git bisect reset &&
|
||||||
|
git checkout master^ &&
|
||||||
|
HEAD=$(git rev-parse --verify HEAD) &&
|
||||||
|
git bisect start &&
|
||||||
|
test $HEAD = $(cat .git/head-name) &&
|
||||||
|
git bisect reset &&
|
||||||
|
test $HEAD = $(git rev-parse --verify HEAD)
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
test_done
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user