* [PATCH v3 1/1] bisect: add support for bisecting bare repositories
@ 2011-08-09 2:11 Jon Seymour
2011-08-09 17:26 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Jon Seymour @ 2011-08-09 2:11 UTC (permalink / raw)
To: git; +Cc: gitster, chriscool, j6t, jnareb, jrnieder, Jon Seymour
This extension to js/bisect-no-checkout adds support for bisecting bare repositories.
It does this by relaxing the requirement that git bisect is invoked in a repository with a working tree and by defaulting to --no-checkout in the case of 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>
---
Documentation/git-bisect.txt | 2 ++
git-bisect.sh | 8 ++++++--
git.c | 2 +-
t/t6030-bisect-porcelain.sh | 31 +++++++++++++++++++++++++++++++
4 files changed, 40 insertions(+), 3 deletions(-)
v3: squashed entire series.
diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt
index 41e6ca8..e4f46bc 100644
--- a/Documentation/git-bisect.txt
+++ b/Documentation/git-bisect.txt
@@ -273,6 +273,8 @@ it point to the commit that should be tested.
+
This option may be useful when the test you would perform in each step
does not require a checked out tree.
++
+If the repository is bare, `--no-checkout` is assumed.
EXAMPLES
--------
diff --git a/git-bisect.sh b/git-bisect.sh
index 22c4da5..e0ca3fb 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -29,7 +29,6 @@ Please use "git help bisect" to get the full man page.'
OPTIONS_SPEC=
. git-sh-setup
. git-sh-i18n
-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"
@@ -79,7 +78,12 @@ bisect_start() {
orig_args=$(git rev-parse --sq-quote "$@")
bad_seen=0
eval=''
- mode=''
+ if test "z$(git rev-parse --is-bare-repository)" != zfalse
+ then
+ mode=--no-checkout
+ else
+ mode=''
+ fi
while [ $# -gt 0 ]; do
arg="$1"
case "$arg" in
diff --git a/git.c b/git.c
index 8828c18..7fdcab2 100644
--- a/git.c
+++ b/git.c
@@ -320,7 +320,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "annotate", cmd_annotate, RUN_SETUP },
{ "apply", cmd_apply, RUN_SETUP_GENTLY },
{ "archive", cmd_archive },
- { "bisect--helper", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },
+ { "bisect--helper", cmd_bisect__helper, RUN_SETUP },
{ "blame", cmd_blame, RUN_SETUP },
{ "branch", cmd_branch, RUN_SETUP },
{ "bundle", cmd_bundle, RUN_SETUP_GENTLY },
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index 4fb7d11..62125ec 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -592,6 +592,37 @@ test_expect_success 'erroring out when using bad path parameters' '
grep "bad path parameters" error.txt
'
+test_expect_success 'test bisection on bare repo - --no-checkout specified' '
+ git clone --bare . bare.nocheckout &&
+ (
+ cd bare.nocheckout &&
+ git bisect start --no-checkout &&
+ git bisect good $HASH1 &&
+ git bisect bad $HASH4 &&
+ git bisect run eval \
+ "test \$(git rev-list BISECT_HEAD ^$HASH2 --max-count=1 | wc -l) = 0" \
+ >../nocheckout.log &&
+ git bisect reset
+ ) &&
+ grep "$HASH3 is the first bad commit" nocheckout.log
+'
+
+
+test_expect_success 'test bisection on bare repo - --no-checkout defaulted' '
+ git clone --bare . bare.defaulted &&
+ (
+ cd bare.defaulted &&
+ git bisect start &&
+ git bisect good $HASH1 &&
+ git bisect bad $HASH4 &&
+ git bisect run eval \
+ "test \$(git rev-list BISECT_HEAD ^$HASH2 --max-count=1 | wc -l) = 0" \
+ >../defaulted.log &&
+ git bisect reset
+ ) &&
+ grep "$HASH3 is the first bad commit" defaulted.log
+'
+
#
# This creates a broken branch which cannot be checked out because
# the tree created has been deleted.
--
1.7.6.523.g2ad34
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3 1/1] bisect: add support for bisecting bare repositories
2011-08-09 2:11 [PATCH v3 1/1] bisect: add support for bisecting bare repositories Jon Seymour
@ 2011-08-09 17:26 ` Junio C Hamano
2011-08-09 23:12 ` Jon Seymour
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2011-08-09 17:26 UTC (permalink / raw)
To: Jon Seymour; +Cc: git, chriscool, j6t, jnareb, jrnieder
Jon Seymour <jon.seymour@gmail.com> writes:
> This extension to js/bisect-no-checkout adds support for bisecting bare repositories.
>
> It does this by relaxing the requirement that git bisect is invoked in a repository with a working tree and by defaulting to --no-checkout in the case of a bare repository.
>
> Two tests are included to demonstrate this behaviour.
I'd wrap the long line myself but next time please be careful.
> diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
> index 4fb7d11..62125ec 100755
> --- a/t/t6030-bisect-porcelain.sh
> +++ b/t/t6030-bisect-porcelain.sh
> @@ -592,6 +592,37 @@ test_expect_success 'erroring out when using bad path parameters' '
> grep "bad path parameters" error.txt
> '
>
> +test_expect_success 'test bisection on bare repo - --no-checkout specified' '
> + git clone --bare . bare.nocheckout &&
> + (
> + cd bare.nocheckout &&
> + git bisect start --no-checkout &&
> + git bisect good $HASH1 &&
> + git bisect bad $HASH4 &&
> + git bisect run eval \
> + "test \$(git rev-list BISECT_HEAD ^$HASH2 --max-count=1 | wc -l) = 0" \
> + >../nocheckout.log &&
> + git bisect reset
> + ) &&
> + grep "$HASH3 is the first bad commit" nocheckout.log
> +'
git-bisect does not have any cd_to_toplevel so with a working tree you can
run a bisection from a subdirectory, it seems. I wonder what would happen
if you did "cd bare.nocheckout/objects" or something silly like that.
Just wondering...
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3 1/1] bisect: add support for bisecting bare repositories
2011-08-09 17:26 ` Junio C Hamano
@ 2011-08-09 23:12 ` Jon Seymour
0 siblings, 0 replies; 3+ messages in thread
From: Jon Seymour @ 2011-08-09 23:12 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, chriscool, j6t, jnareb, jrnieder
On Wed, Aug 10, 2011 at 3:26 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Jon Seymour <jon.seymour@gmail.com> writes:
>
>> This extension to js/bisect-no-checkout adds support for bisecting bare repositories.
>>
>> It does this by relaxing the requirement that git bisect is invoked in a repository with a working tree and by defaulting to --no-checkout in the case of a bare repository.
>>
>> Two tests are included to demonstrate this behaviour.
>
> I'd wrap the long line myself but next time please be careful.
>
>> diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
>> index 4fb7d11..62125ec 100755
>> --- a/t/t6030-bisect-porcelain.sh
>> +++ b/t/t6030-bisect-porcelain.sh
>> @@ -592,6 +592,37 @@ test_expect_success 'erroring out when using bad path parameters' '
>> grep "bad path parameters" error.txt
>> '
>>
>> +test_expect_success 'test bisection on bare repo - --no-checkout specified' '
>> + git clone --bare . bare.nocheckout &&
>> + (
>> + cd bare.nocheckout &&
>> + git bisect start --no-checkout &&
>> + git bisect good $HASH1 &&
>> + git bisect bad $HASH4 &&
>> + git bisect run eval \
>> + "test \$(git rev-list BISECT_HEAD ^$HASH2 --max-count=1 | wc -l) = 0" \
>> + >../nocheckout.log &&
>> + git bisect reset
>> + ) &&
>> + grep "$HASH3 is the first bad commit" nocheckout.log
>> +'
>
> git-bisect does not have any cd_to_toplevel so with a working tree you can
> run a bisection from a subdirectory, it seems. I wonder what would happen
> if you did "cd bare.nocheckout/objects" or something silly like that.
>
> Just wondering...
>
Well, nothing obviously breaks...
expecting success:
git clone --bare . bare.silly &&
(
cd bare.silly/objects &&
git bisect start &&
git bisect good $HASH1 &&
git bisect bad $HASH4 &&
git bisect run eval \
"test \$(git rev-list BISECT_HEAD ^$HASH2 --max-count=1 | wc -l) = 0" \
>../../silly.log &&
git bisect reset
) &&
grep "$HASH3 is the first bad commit" silly.log
Cloning into bare repository bare.silly...
done.
Bisecting: 0 revisions left to test after this (roughly 1 step)
[3de952f2416b6084f557ec417709eac740c6818c] Add <3: Another new day for
git> into <hello>.
3de952f2416b6084f557ec417709eac740c6818c is the first bad commit
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-08-09 23:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-09 2:11 [PATCH v3 1/1] bisect: add support for bisecting bare repositories Jon Seymour
2011-08-09 17:26 ` Junio C Hamano
2011-08-09 23:12 ` Jon Seymour
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).