bisect: add support for bisecting bare repositories
This enhances the support for bisecting history in bare repositories. The "git bisect" command no longer needs to be run inside a repository with a working tree; it defaults to --no-checkout when run in a bare repository. Two tests are included to demonstrate this behaviour. Suggested-by: Junio C Hamano <gitster@pobox.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Jon Seymour <jon.seymour@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jon Seymour committed
Aug 9, 2011 at 12:11 UTC
24c512803dadf61b2f7f8965735b7c3a03f6147e
4 files changed
+40
-3
Documentation/git-bisect.txt
+2
@@ -273,6 +273,8 @@ it point to the commit that should be tested.
273
+
274
This option may be useful when the test you would perform in each step
275
does not require a checked out tree.
276
++
277
+If the repository is bare, `--no-checkout` is assumed.
278
279
EXAMPLES
280
--------
git-bisect.sh
+6
-2
@@ -29,7 +29,6 @@ Please use "git help bisect" to get the full man page.'
29
OPTIONS_SPEC=
30
. git-sh-setup
31
. git-sh-i18n
32
-require_work_tree
32
33
_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
34
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
@@ -79,7 +78,12 @@ bisect_start() {
78
orig_args=$(git rev-parse --sq-quote "$@")
79
bad_seen=0
80
eval=''
82
- mode=''
81
+ if test "z$(git rev-parse --is-bare-repository)" != zfalse
82
+ then
83
+ mode=--no-checkout
84
+ else
85
+ mode=''
86
+ fi
87
while [ $# -gt 0 ]; do
88
arg="$1"
89
case "$arg" in
git.c
+1
-1
@@ -320,7 +320,7 @@ static void handle_internal_command(int argc, const char **argv)
320
{ "annotate", cmd_annotate, RUN_SETUP },
321
{ "apply", cmd_apply, RUN_SETUP_GENTLY },
322
{ "archive", cmd_archive },
323
- { "bisect--helper", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },
323
+ { "bisect--helper", cmd_bisect__helper, RUN_SETUP },
324
{ "blame", cmd_blame, RUN_SETUP },
325
{ "branch", cmd_branch, RUN_SETUP },
326
{ "bundle", cmd_bundle, RUN_SETUP_GENTLY },
t/t6030-bisect-porcelain.sh
+31
@@ -592,6 +592,37 @@ test_expect_success 'erroring out when using bad path parameters' '
592
grep "bad path parameters" error.txt
593
'
594
595
+test_expect_success 'test bisection on bare repo - --no-checkout specified' '
596
+ git clone --bare . bare.nocheckout &&
597
+ (
598
+ cd bare.nocheckout &&
599
+ git bisect start --no-checkout &&
600
+ git bisect good $HASH1 &&
601
+ git bisect bad $HASH4 &&
602
+ git bisect run eval \
603
+ "test \$(git rev-list BISECT_HEAD ^$HASH2 --max-count=1 | wc -l) = 0" \
604
+ >../nocheckout.log &&
605
+ git bisect reset
606
+ ) &&
607
+ grep "$HASH3 is the first bad commit" nocheckout.log
608
+'
609
+
610
+
611
+test_expect_success 'test bisection on bare repo - --no-checkout defaulted' '
612
+ git clone --bare . bare.defaulted &&
613
+ (
614
+ cd bare.defaulted &&
615
+ git bisect start &&
616
+ git bisect good $HASH1 &&
617
+ git bisect bad $HASH4 &&
618
+ git bisect run eval \
619
+ "test \$(git rev-list BISECT_HEAD ^$HASH2 --max-count=1 | wc -l) = 0" \
620
+ >../defaulted.log &&
621
+ git bisect reset
622
+ ) &&
623
+ grep "$HASH3 is the first bad commit" defaulted.log
624
+'
625
+
626
#
627
# This creates a broken branch which cannot be checked out because
628
# the tree created has been deleted.