{"thread":{"id":"28051","subject":"[PATCH v3 1/1] bisect: add support for bisecting bare repositories","startedAt":"2011-08-09T02:11:54Z","lastAt":"2011-08-09T23:12:50Z","messageCount":3,"participants":["Jon Seymour","Junio C Hamano"],"isPatch":true,"patchVersion":3,"patchTotal":1},"messages":[{"id":"173194","messageId":"1312855914-610-1-git-send-email-jon.seymour@gmail.com","threadId":"28051","inReplyTo":null,"subject":"[PATCH v3 1/1] bisect: add support for bisecting bare repositories","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-09T02:11:54Z","receivedAt":"2011-08-09T02:11:54Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"This extension to js/bisect-no-checkout adds support for bisecting bare repositories.\n\nIt 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.\n\nTwo tests are included to demonstrate this behaviour.\n\nSuggested-by: Junio C Hamano <gitster@pobox.com>\nReviewed-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n Documentation/git-bisect.txt |    2 ++\n git-bisect.sh                |    8 ++++++--\n git.c                        |    2 +-\n t/t6030-bisect-porcelain.sh  |   31 +++++++++++++++++++++++++++++++\n 4 files changed, 40 insertions(+), 3 deletions(-)\n\nv3: squashed entire series.\n\ndiff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt\nindex 41e6ca8..e4f46bc 100644\n--- a/Documentation/git-bisect.txt\n+++ b/Documentation/git-bisect.txt\n@@ -273,6 +273,8 @@ it point to the commit that should be tested.\n +\n This option may be useful when the test you would perform in each step\n does not require a checked out tree.\n++\n+If the repository is bare, `--no-checkout` is assumed.\n \n EXAMPLES\n --------\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 22c4da5..e0ca3fb 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -29,7 +29,6 @@ Please use \"git help bisect\" to get the full man page.'\n OPTIONS_SPEC=\n . git-sh-setup\n . git-sh-i18n\n-require_work_tree\n \n _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'\n _x40=\"$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40\"\n@@ -79,7 +78,12 @@ bisect_start() {\n \torig_args=$(git rev-parse --sq-quote \"$@\")\n \tbad_seen=0\n \teval=''\n-\tmode=''\n+\tif test \"z$(git rev-parse --is-bare-repository)\" != zfalse\n+\tthen\n+\t\tmode=--no-checkout\n+\telse\n+\t\tmode=''\n+\tfi\n \twhile [ $# -gt 0 ]; do\n \t\targ=\"$1\"\n \t\tcase \"$arg\" in\ndiff --git a/git.c b/git.c\nindex 8828c18..7fdcab2 100644\n--- a/git.c\n+++ b/git.c\n@@ -320,7 +320,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"annotate\", cmd_annotate, RUN_SETUP },\n \t\t{ \"apply\", cmd_apply, RUN_SETUP_GENTLY },\n \t\t{ \"archive\", cmd_archive },\n-\t\t{ \"bisect--helper\", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },\n+\t\t{ \"bisect--helper\", cmd_bisect__helper, RUN_SETUP },\n \t\t{ \"blame\", cmd_blame, RUN_SETUP },\n \t\t{ \"branch\", cmd_branch, RUN_SETUP },\n \t\t{ \"bundle\", cmd_bundle, RUN_SETUP_GENTLY },\ndiff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh\nindex 4fb7d11..62125ec 100755\n--- a/t/t6030-bisect-porcelain.sh\n+++ b/t/t6030-bisect-porcelain.sh\n@@ -592,6 +592,37 @@ test_expect_success 'erroring out when using bad path parameters' '\n \tgrep \"bad path parameters\" error.txt\n '\n \n+test_expect_success 'test bisection on bare repo - --no-checkout specified' '\n+\tgit clone --bare . bare.nocheckout &&\n+\t(\n+\t\tcd bare.nocheckout &&\n+\t\tgit bisect start --no-checkout &&\n+\t\tgit bisect good $HASH1 &&\n+\t\tgit bisect bad $HASH4 &&\n+\t\tgit bisect run eval \\\n+\t\t\t\"test \\$(git rev-list BISECT_HEAD ^$HASH2 --max-count=1 | wc -l) = 0\" \\\n+\t\t\t>../nocheckout.log &&\n+\t\tgit bisect reset\n+\t) &&\n+\tgrep \"$HASH3 is the first bad commit\" nocheckout.log\n+'\n+\n+\n+test_expect_success 'test bisection on bare repo - --no-checkout defaulted' '\n+\tgit clone --bare . bare.defaulted &&\n+\t(\n+\t\tcd bare.defaulted &&\n+\t\tgit bisect start &&\n+\t\tgit bisect good $HASH1 &&\n+\t\tgit bisect bad $HASH4 &&\n+\t\tgit bisect run eval \\\n+\t\t\t\"test \\$(git rev-list BISECT_HEAD ^$HASH2 --max-count=1 | wc -l) = 0\" \\\n+\t\t\t>../defaulted.log &&\n+\t\tgit bisect reset\n+\t) &&\n+\tgrep \"$HASH3 is the first bad commit\" defaulted.log\n+'\n+\n #\n # This creates a broken branch which cannot be checked out because\n # the tree created has been deleted.\n-- \n1.7.6.523.g2ad34\n"},{"id":"173211","messageId":"7vty9qsdhp.fsf@alter.siamese.dyndns.org","threadId":"28051","inReplyTo":"1312855914-610-1-git-send-email-jon.seymour@gmail.com","subject":"Re: [PATCH v3 1/1] bisect: add support for bisecting bare repositories","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-08-09T17:26:10Z","receivedAt":"2011-08-09T17:26:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jon Seymour <jon.seymour@gmail.com> writes:\n\n> This extension to js/bisect-no-checkout adds support for bisecting bare repositories.\n>\n> 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.\n>\n> Two tests are included to demonstrate this behaviour.\n\nI'd wrap the long line myself but next time please be careful.\n\n> diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh\n> index 4fb7d11..62125ec 100755\n> --- a/t/t6030-bisect-porcelain.sh\n> +++ b/t/t6030-bisect-porcelain.sh\n> @@ -592,6 +592,37 @@ test_expect_success 'erroring out when using bad path parameters' '\n>  \tgrep \"bad path parameters\" error.txt\n>  '\n>  \n> +test_expect_success 'test bisection on bare repo - --no-checkout specified' '\n> +\tgit clone --bare . bare.nocheckout &&\n> +\t(\n> +\t\tcd bare.nocheckout &&\n> +\t\tgit bisect start --no-checkout &&\n> +\t\tgit bisect good $HASH1 &&\n> +\t\tgit bisect bad $HASH4 &&\n> +\t\tgit bisect run eval \\\n> +\t\t\t\"test \\$(git rev-list BISECT_HEAD ^$HASH2 --max-count=1 | wc -l) = 0\" \\\n> +\t\t\t>../nocheckout.log &&\n> +\t\tgit bisect reset\n> +\t) &&\n> +\tgrep \"$HASH3 is the first bad commit\" nocheckout.log\n> +'\n\ngit-bisect does not have any cd_to_toplevel so with a working tree you can\nrun a bisection from a subdirectory, it seems. I wonder what would happen\nif you did \"cd bare.nocheckout/objects\" or something silly like that.\n\nJust wondering...\n"},{"id":"173225","messageId":"CAH3Anrr1eDuG9WNGb168ekMUnRcfEu4TPnGcSnh9TwLpvVMkBw@mail.gmail.com","threadId":"28051","inReplyTo":"7vty9qsdhp.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3 1/1] bisect: add support for bisecting bare repositories","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-09T23:12:50Z","receivedAt":"2011-08-09T23:12:50Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"On Wed, Aug 10, 2011 at 3:26 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Jon Seymour <jon.seymour@gmail.com> writes:\n>\n>> This extension to js/bisect-no-checkout adds support for bisecting bare repositories.\n>>\n>> 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.\n>>\n>> Two tests are included to demonstrate this behaviour.\n>\n> I'd wrap the long line myself but next time please be careful.\n>\n>> diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh\n>> index 4fb7d11..62125ec 100755\n>> --- a/t/t6030-bisect-porcelain.sh\n>> +++ b/t/t6030-bisect-porcelain.sh\n>> @@ -592,6 +592,37 @@ test_expect_success 'erroring out when using bad path parameters' '\n>>       grep \"bad path parameters\" error.txt\n>>  '\n>>\n>> +test_expect_success 'test bisection on bare repo - --no-checkout specified' '\n>> +     git clone --bare . bare.nocheckout &&\n>> +     (\n>> +             cd bare.nocheckout &&\n>> +             git bisect start --no-checkout &&\n>> +             git bisect good $HASH1 &&\n>> +             git bisect bad $HASH4 &&\n>> +             git bisect run eval \\\n>> +                     \"test \\$(git rev-list BISECT_HEAD ^$HASH2 --max-count=1 | wc -l) = 0\" \\\n>> +                     >../nocheckout.log &&\n>> +             git bisect reset\n>> +     ) &&\n>> +     grep \"$HASH3 is the first bad commit\" nocheckout.log\n>> +'\n>\n> git-bisect does not have any cd_to_toplevel so with a working tree you can\n> run a bisection from a subdirectory, it seems. I wonder what would happen\n> if you did \"cd bare.nocheckout/objects\" or something silly like that.\n>\n> Just wondering...\n>\n\nWell, nothing obviously breaks...\n\nexpecting success:\n\tgit clone --bare . bare.silly &&\n\t(\n\t\tcd bare.silly/objects &&\n\t\tgit bisect start &&\n\t\tgit bisect good $HASH1 &&\n\t\tgit bisect bad $HASH4 &&\n\t\tgit bisect run eval \\\n\t\t\t\"test \\$(git rev-list BISECT_HEAD ^$HASH2 --max-count=1 | wc -l) = 0\" \\\n\t\t\t>../../silly.log &&\n\t\tgit bisect reset\n\t) &&\n\tgrep \"$HASH3 is the first bad commit\" silly.log\n\nCloning into bare repository bare.silly...\ndone.\nBisecting: 0 revisions left to test after this (roughly 1 step)\n[3de952f2416b6084f557ec417709eac740c6818c] Add <3: Another new day for\ngit> into <hello>.\n3de952f2416b6084f557ec417709eac740c6818c is the first bad commit\n"}]}