{"thread":{"id":"27999","subject":"[PATCH v14 1/8] bisect: move argument parsing before state modification.","startedAt":"2011-08-02T22:15:54Z","lastAt":"2011-08-03T21:45:06Z","messageCount":20,"participants":["Jon Seymour","Junio C Hamano","Christian Couder","Jonathan Nieder"],"isPatch":true,"patchVersion":14,"patchTotal":8},"messages":[{"id":"172707","messageId":"1312323362-20096-1-git-send-email-jon.seymour@gmail.com","threadId":"27999","inReplyTo":null,"subject":"[PATCH v14 0/8] bisect: Add support for --no-checkout option","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-02T22:15:54Z","receivedAt":"2011-08-02T22:15:54Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Motivation\n==========\nFor some bisection tasks, checking out the commit at each stage of the bisection process is unecessary or undesirable.\n\nThis series adds support for a --no-checkout option to git-bisect.\n\nIf specified on a start command, --no-checkout causes 'git bisect' to update HEAD at each stage of the bisection process instead of checking out the commit at that point. \n\nOne application of the --no-checkout option is to find, within a partially damaged repository, a commit that has at least one parent whose graph is fully reachable in the sense of 'git pack-objects'.\n\nFor example:\n\n\tgit bisect start BISECT_HEAD <some-known-good-commit> <boundary-commits> --no-checkout\n\tgit bisect run eval '\n\t\trc=1;\n\t\tif git rev-list --objects BISECT_HEAD >tmp.$$; then\n\t\t   git pack-objects --stdout >/dev/null < tmp.$$ && rc=0;\n\t\tfi;\n\t\trm tmp.$$;\n\t\ttest $rc -eq 0;'\n\n<some-known-good-commit> is a known good commit, for which the test passes.\n<boundary-commits> are commits chosen to prevent the bisection visiting missing or corrupt commit objects.\n\nAssuming this git bisect run completes successfully, bisect/bad will refer to a commit which has at least one parent that is fully reachable in the sense of 'git pack-objects'.\n\nPatch Synopsis\n==============\n\nRemediation\n-----------\nPatch 1/8 changes existing behaviour in the case that an invalid revision argument is supplied to 'git bisect start'. In particular, in this case, bisection state is neither created or modified if argument validation fails. Previously, existing bisection state would be cleared even if the revision arguments were subsequently determined to be invalid. \t\n\nPatch 2/8 remediates a potential flaw that might hide a failure in a chain of pasted statements.\n\nPatch 3/8 adds a test which documents the existing behaviour of git bisect in the presence of tree damage.\n\nNew Function\n------------\nPatch 4/8 modifies the C code that supports bisection.\nPatch 5/8 modifies porcelain to enable option exposed by 4/8.\nPatch 6/8 adds some tests.\nPatch 7/8 adds some documentation.\nPatch 8/8 --no-checkout bisections now update BISECT_HEAD rather than HEAD.\n\nRevision History\n----------------\nv14:\n\tReverted --bisect-mode aspect of v13 change so C code matches v11.\nv13:\n\tFollowing suggestions from Junio:\n\t * Replaced BISECT_NO_CHECKOUT control file with BISECT_MODE. \n\t * Changed name of internal option on bisect--helper from --no-checkout to --bisect-mode=checkout|update-ref.\n\t * Changed --no-checkout bisections to update BISECT_HEAD instead of HEAD.\t\nv11:\n\tRemoved support for --update-ref=<ref>, per Junio's preference.\nv10:\n\tChanged the way deferred statements are connected. Reverted some whitespace minimization.\nv8:\n\tFurther feedback from Christian Couder. Support --update-ref <ref>.\nv6: \n\tThis series includes numerous improvements suggested by Christian Couder.\nReworks: \n\t\"bisect: allow git bisect to be used with repos containing damaged trees.\" \n\tReplaced --ignore-checkout-failure with --no-checkout option suggested by Junio.\n\nJon Seymour (8):\n  bisect: move argument parsing before state modification.\n  bisect: use && to connect statements that are deferred with eval.\n  bisect: add tests to document expected behaviour in presence of\n    broken trees.\n  bisect: introduce support for --no-checkout option.\n  bisect: introduce --no-checkout support into porcelain.\n  bisect: add tests for the --no-checkout option.\n  bisect: add documentation for --no-checkout option.\n  bisect: change bisect function to update BISECT_HEAD, rather than\n    HEAD.\n\n Documentation/git-bisect.txt |   32 ++++++++++-\n bisect.c                     |   33 +++++++----\n bisect.h                     |    2 +-\n builtin/bisect--helper.c     |    7 ++-\n git-bisect.sh                |  113 ++++++++++++++++++++++--------------\n t/t6030-bisect-porcelain.sh  |  132 +++++++++++++++++++++++++++++++++++++++++-\n 6 files changed, 258 insertions(+), 61 deletions(-)\n\n-- \n1.7.6.353.gb3ae7e\n"},{"id":"172706","messageId":"1312323362-20096-2-git-send-email-jon.seymour@gmail.com","threadId":"27999","inReplyTo":"1312323362-20096-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v14 1/8] bisect: move argument parsing before state modification.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-02T22:15:55Z","receivedAt":"2011-08-02T22:15:55Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Currently 'git bisect start' modifies some state prior to checking\nthat its arguments are valid.\n\nThis change moves argument validation before state modification\nwith the effect that state modification does not occur\nunless argument validations succeeds.\n\nAn existing test is changed to check that new bisect state\nis not created if arguments are invalid.\n\nA new test is added to check that existing bisect state\nis not modified if arguments are invalid.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n git-bisect.sh               |   66 +++++++++++++++++++++---------------------\n t/t6030-bisect-porcelain.sh |   14 +++++++--\n 2 files changed, 44 insertions(+), 36 deletions(-)\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex b2186a8..20f6dd5 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -60,6 +60,39 @@ bisect_autostart() {\n \n bisect_start() {\n \t#\n+\t# Check for one bad and then some good revisions.\n+\t#\n+\thas_double_dash=0\n+\tfor arg; do\n+\t    case \"$arg\" in --) has_double_dash=1; break ;; esac\n+\tdone\n+\torig_args=$(git rev-parse --sq-quote \"$@\")\n+\tbad_seen=0\n+\teval=''\n+\twhile [ $# -gt 0 ]; do\n+\t    arg=\"$1\"\n+\t    case \"$arg\" in\n+\t    --)\n+\t\tshift\n+\t\tbreak\n+\t\t;;\n+\t    *)\n+\t\trev=$(git rev-parse -q --verify \"$arg^{commit}\") || {\n+\t\t    test $has_double_dash -eq 1 &&\n+\t\t\tdie \"$(eval_gettext \"'\\$arg' does not appear to be a valid revision\")\"\n+\t\t    break\n+\t\t}\n+\t\tcase $bad_seen in\n+\t\t0) state='bad' ; bad_seen=1 ;;\n+\t\t*) state='good' ;;\n+\t\tesac\n+\t\teval=\"$eval bisect_write '$state' '$rev' 'nolog'; \"\n+\t\tshift\n+\t\t;;\n+\t    esac\n+\tdone\n+\n+\t#\n \t# Verify HEAD.\n \t#\n \thead=$(GIT_DIR=\"$GIT_DIR\" git symbolic-ref -q HEAD) ||\n@@ -98,39 +131,6 @@ bisect_start() {\n \tbisect_clean_state || exit\n \n \t#\n-\t# Check for one bad and then some good revisions.\n-\t#\n-\thas_double_dash=0\n-\tfor arg; do\n-\t    case \"$arg\" in --) has_double_dash=1; break ;; esac\n-\tdone\n-\torig_args=$(git rev-parse --sq-quote \"$@\")\n-\tbad_seen=0\n-\teval=''\n-\twhile [ $# -gt 0 ]; do\n-\t    arg=\"$1\"\n-\t    case \"$arg\" in\n-\t    --)\n-\t\tshift\n-\t\tbreak\n-\t\t;;\n-\t    *)\n-\t\trev=$(git rev-parse -q --verify \"$arg^{commit}\") || {\n-\t\t    test $has_double_dash -eq 1 &&\n-\t\t\tdie \"$(eval_gettext \"'\\$arg' does not appear to be a valid revision\")\"\n-\t\t    break\n-\t\t}\n-\t\tcase $bad_seen in\n-\t\t0) state='bad' ; bad_seen=1 ;;\n-\t\t*) state='good' ;;\n-\t\tesac\n-\t\teval=\"$eval bisect_write '$state' '$rev' 'nolog'; \"\n-\t\tshift\n-\t\t;;\n-\t    esac\n-\tdone\n-\n-\t#\n \t# Change state.\n \t# In case of mistaken revs or checkout error, or signals received,\n \t# \"bisect_auto_next\" below may exit or misbehave.\ndiff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh\nindex b5063b6..b3d1b14 100755\n--- a/t/t6030-bisect-porcelain.sh\n+++ b/t/t6030-bisect-porcelain.sh\n@@ -138,15 +138,23 @@ test_expect_success 'bisect start: back in good branch' '\n \tgrep \"* other\" branch.output > /dev/null\n '\n \n-test_expect_success 'bisect start: no \".git/BISECT_START\" if junk rev' '\n-\tgit bisect start $HASH4 $HASH1 -- &&\n-\tgit bisect good &&\n+test_expect_success 'bisect start: no \".git/BISECT_START\" created if junk rev' '\n+\tgit bisect reset &&\n \ttest_must_fail git bisect start $HASH4 foo -- &&\n \tgit branch > branch.output &&\n \tgrep \"* other\" branch.output > /dev/null &&\n \ttest_must_fail test -e .git/BISECT_START\n '\n \n+test_expect_success 'bisect start: existing \".git/BISECT_START\" not modified if junk rev' '\n+\tgit bisect start $HASH4 $HASH1 -- &&\n+\tgit bisect good &&\n+\tcp .git/BISECT_START saved &&\n+\ttest_must_fail git bisect start $HASH4 foo -- &&\n+\tgit branch > branch.output &&\n+\tgrep \"* (no branch)\" branch.output > /dev/null &&\n+\ttest_cmp saved .git/BISECT_START\n+'\n test_expect_success 'bisect start: no \".git/BISECT_START\" if mistaken rev' '\n \tgit bisect start $HASH4 $HASH1 -- &&\n \tgit bisect good &&\n-- \n1.7.6.353.gb3ae7e\n"},{"id":"172712","messageId":"1312323362-20096-3-git-send-email-jon.seymour@gmail.com","threadId":"27999","inReplyTo":"1312323362-20096-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v14 2/8] bisect: use && to connect statements that are deferred with eval.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-02T22:15:56Z","receivedAt":"2011-08-02T22:15:56Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Christian Couder pointed out that the existing eval strategy\nswallows an initial non-zero return. Using && to connect\nthe statements should fix this.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n git-bisect.sh |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 20f6dd5..a44ffe1 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -86,7 +86,7 @@ bisect_start() {\n \t\t0) state='bad' ; bad_seen=1 ;;\n \t\t*) state='good' ;;\n \t\tesac\n-\t\teval=\"$eval bisect_write '$state' '$rev' 'nolog'; \"\n+\t\teval=\"$eval bisect_write '$state' '$rev' 'nolog' &&\"\n \t\tshift\n \t\t;;\n \t    esac\n@@ -145,7 +145,7 @@ bisect_start() {\n \t#\n \techo \"$start_head\" >\"$GIT_DIR/BISECT_START\" &&\n \tgit rev-parse --sq-quote \"$@\" >\"$GIT_DIR/BISECT_NAMES\" &&\n-\teval \"$eval\" &&\n+\teval \"$eval true\" &&\n \techo \"git bisect start$orig_args\" >>\"$GIT_DIR/BISECT_LOG\" || exit\n \t#\n \t# Check if we can proceed to the next bisect state.\n-- \n1.7.6.353.gb3ae7e\n"},{"id":"172708","messageId":"1312323362-20096-4-git-send-email-jon.seymour@gmail.com","threadId":"27999","inReplyTo":"1312323362-20096-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v14 3/8] bisect: add tests to document expected behaviour in presence of broken trees.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-02T22:15:57Z","receivedAt":"2011-08-02T22:15:57Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"If the repo is broken, we expect bisect to fail.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n t/t6030-bisect-porcelain.sh |   48 +++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 48 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh\nindex b3d1b14..9ae2de8 100755\n--- a/t/t6030-bisect-porcelain.sh\n+++ b/t/t6030-bisect-porcelain.sh\n@@ -581,5 +581,53 @@ test_expect_success 'erroring out when using bad path parameters' '\n '\n \n #\n+# This creates a broken branch which cannot be checked out because\n+# the tree created has been deleted.\n #\n+# H1-H2-H3-H4-H5-H6-H7  <--other\n+#            \\\n+#             S5-S6'-S7'-S8'-S9  <--broken\n+#\n+# Commits marked with ' have a missing tree.\n+#\n+test_expect_success 'broken branch creation' '\n+\tgit bisect reset &&\n+\tgit checkout -b broken $HASH4 &&\n+\tgit tag BROKEN_HASH4 $HASH4 &&\n+\tadd_line_into_file \"5(broken): first line on a broken branch\" hello2 &&\n+\tgit tag BROKEN_HASH5 &&\n+\tmkdir missing &&\n+\t:> missing/MISSING &&\n+\tgit add missing/MISSING &&\n+\tgit commit -m \"6(broken): Added file that will be deleted\"\n+\tgit tag BROKEN_HASH6 &&\n+\tadd_line_into_file \"7(broken): second line on a broken branch\" hello2 &&\n+\tgit tag BROKEN_HASH7 &&\n+\tadd_line_into_file \"8(broken): third line on a broken branch\" hello2 &&\n+\tgit tag BROKEN_HASH8 &&\n+\tgit rm missing/MISSING &&\n+\tgit commit -m \"9(broken): Remove missing file\"\n+\tgit tag BROKEN_HASH9 &&\n+\trm .git/objects/39/f7e61a724187ab767d2e08442d9b6b9dab587d\n+'\n+\n+echo \"\" > expected.ok\n+cat > expected.missing-tree.default <<EOF\n+fatal: unable to read tree 39f7e61a724187ab767d2e08442d9b6b9dab587d\n+EOF\n+\n+test_expect_success 'bisect fails if tree is broken on start commit' '\n+\tgit bisect reset &&\n+\ttest_must_fail git bisect start BROKEN_HASH7 BROKEN_HASH4 2>error.txt &&\n+\ttest_cmp expected.missing-tree.default error.txt\n+'\n+\n+test_expect_success 'bisect fails if tree is broken on trial commit' '\n+\tgit bisect reset &&\n+\ttest_must_fail git bisect start BROKEN_HASH9 BROKEN_HASH4 2>error.txt &&\n+\tgit reset --hard broken &&\n+\tgit checkout broken &&\n+\ttest_cmp expected.missing-tree.default error.txt\n+'\n+\n test_done\n-- \n1.7.6.353.gb3ae7e\n"},{"id":"172709","messageId":"1312323362-20096-5-git-send-email-jon.seymour@gmail.com","threadId":"27999","inReplyTo":"1312323362-20096-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v14 4/8] bisect: introduce support for --no-checkout option.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-02T22:15:58Z","receivedAt":"2011-08-02T22:15:58Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"If --no-checkout is specified, then the bisection process uses:\n\n\tgit update-ref --no-deref HEAD <trial>\n\nat each trial instead of:\n\n\tgit checkout <trial>\n\nImproved-by: Christian Couder <chriscool@tuxfamily.org>\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n bisect.c                 |   33 ++++++++++++++++++++++-----------\n bisect.h                 |    2 +-\n builtin/bisect--helper.c |    7 +++++--\n 3 files changed, 28 insertions(+), 14 deletions(-)\n\ndiff --git a/bisect.c b/bisect.c\nindex dd7e8ed..0427117 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -24,6 +24,7 @@ struct argv_array {\n \n static const char *argv_checkout[] = {\"checkout\", \"-q\", NULL, \"--\", NULL};\n static const char *argv_show_branch[] = {\"show-branch\", NULL, NULL};\n+static const char *argv_update_ref[] = {\"update-ref\", \"--no-deref\", \"HEAD\", NULL, NULL};\n \n /* bits #0-15 in revision.h */\n \n@@ -707,16 +708,23 @@ static void mark_expected_rev(char *bisect_rev_hex)\n \t\tdie(\"closing file %s: %s\", filename, strerror(errno));\n }\n \n-static int bisect_checkout(char *bisect_rev_hex)\n+static int bisect_checkout(char *bisect_rev_hex, int no_checkout)\n {\n \tint res;\n \n \tmark_expected_rev(bisect_rev_hex);\n \n \targv_checkout[2] = bisect_rev_hex;\n-\tres = run_command_v_opt(argv_checkout, RUN_GIT_CMD);\n-\tif (res)\n-\t\texit(res);\n+\tif (no_checkout) {\n+\t\targv_update_ref[3] = bisect_rev_hex;\n+\t\tif (run_command_v_opt(argv_update_ref, RUN_GIT_CMD))\n+\t\t\tdie(\"update-ref --no-deref HEAD failed on %s\",\n+\t\t\t    bisect_rev_hex);\n+\t} else {\n+\t\tres = run_command_v_opt(argv_checkout, RUN_GIT_CMD);\n+\t\tif (res)\n+\t\t\texit(res);\n+\t}\n \n \targv_show_branch[1] = bisect_rev_hex;\n \treturn run_command_v_opt(argv_show_branch, RUN_GIT_CMD);\n@@ -788,7 +796,7 @@ static void handle_skipped_merge_base(const unsigned char *mb)\n  * - If one is \"skipped\", we can't know but we should warn.\n  * - If we don't know, we should check it out and ask the user to test.\n  */\n-static void check_merge_bases(void)\n+static void check_merge_bases(int no_checkout)\n {\n \tstruct commit_list *result;\n \tint rev_nr;\n@@ -806,7 +814,7 @@ static void check_merge_bases(void)\n \t\t\thandle_skipped_merge_base(mb);\n \t\t} else {\n \t\t\tprintf(\"Bisecting: a merge base must be tested\\n\");\n-\t\t\texit(bisect_checkout(sha1_to_hex(mb)));\n+\t\t\texit(bisect_checkout(sha1_to_hex(mb), no_checkout));\n \t\t}\n \t}\n \n@@ -849,7 +857,7 @@ static int check_ancestors(const char *prefix)\n  * If a merge base must be tested by the user, its source code will be\n  * checked out to be tested by the user and we will exit.\n  */\n-static void check_good_are_ancestors_of_bad(const char *prefix)\n+static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)\n {\n \tconst char *filename = git_path(\"BISECT_ANCESTORS_OK\");\n \tstruct stat st;\n@@ -868,7 +876,7 @@ static void check_good_are_ancestors_of_bad(const char *prefix)\n \n \t/* Check if all good revs are ancestor of the bad rev. */\n \tif (check_ancestors(prefix))\n-\t\tcheck_merge_bases();\n+\t\tcheck_merge_bases(no_checkout);\n \n \t/* Create file BISECT_ANCESTORS_OK. */\n \tfd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600);\n@@ -908,8 +916,11 @@ static void show_diff_tree(const char *prefix, struct commit *commit)\n  * We use the convention that exiting with an exit code 10 means that\n  * the bisection process finished successfully.\n  * In this case the calling shell script should exit 0.\n+ *\n+ * If no_checkout is non-zero, the bisection process does not\n+ * checkout the trial commit but instead simply updates HEAD.\n  */\n-int bisect_next_all(const char *prefix)\n+int bisect_next_all(const char *prefix, int no_checkout)\n {\n \tstruct rev_info revs;\n \tstruct commit_list *tried;\n@@ -920,7 +931,7 @@ int bisect_next_all(const char *prefix)\n \tif (read_bisect_refs())\n \t\tdie(\"reading bisect refs failed\");\n \n-\tcheck_good_are_ancestors_of_bad(prefix);\n+\tcheck_good_are_ancestors_of_bad(prefix, no_checkout);\n \n \tbisect_rev_setup(&revs, prefix, \"%s\", \"^%s\", 1);\n \trevs.limited = 1;\n@@ -966,6 +977,6 @@ int bisect_next_all(const char *prefix)\n \t       \"(roughly %d step%s)\\n\", nr, (nr == 1 ? \"\" : \"s\"),\n \t       steps, (steps == 1 ? \"\" : \"s\"));\n \n-\treturn bisect_checkout(bisect_rev_hex);\n+\treturn bisect_checkout(bisect_rev_hex, no_checkout);\n }\n \ndiff --git a/bisect.h b/bisect.h\nindex 0862ce5..22f2e4d 100644\n--- a/bisect.h\n+++ b/bisect.h\n@@ -27,7 +27,7 @@ struct rev_list_info {\n \tconst char *header_prefix;\n };\n \n-extern int bisect_next_all(const char *prefix);\n+extern int bisect_next_all(const char *prefix, int no_checkout);\n \n extern int estimate_bisect_steps(int all);\n \ndiff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c\nindex 5b22639..d96a193 100644\n--- a/builtin/bisect--helper.c\n+++ b/builtin/bisect--helper.c\n@@ -4,16 +4,19 @@\n #include \"bisect.h\"\n \n static const char * const git_bisect_helper_usage[] = {\n-\t\"git bisect--helper --next-all\",\n+\t\"git bisect--helper --next-all [--no-checkout]\",\n \tNULL\n };\n \n int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n {\n \tint next_all = 0;\n+\tint no_checkout = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOLEAN(0, \"next-all\", &next_all,\n \t\t\t    \"perform 'git bisect next'\"),\n+\t\tOPT_BOOLEAN(0, \"no-checkout\", &no_checkout,\n+\t\t\t    \"update HEAD instead of checking out the current commit\"),\n \t\tOPT_END()\n \t};\n \n@@ -24,5 +27,5 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n \t\tusage_with_options(git_bisect_helper_usage, options);\n \n \t/* next-all */\n-\treturn bisect_next_all(prefix);\n+\treturn bisect_next_all(prefix, no_checkout);\n }\n-- \n1.7.6.353.gb3ae7e\n"},{"id":"172711","messageId":"1312323362-20096-6-git-send-email-jon.seymour@gmail.com","threadId":"27999","inReplyTo":"1312323362-20096-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v14 5/8] bisect: introduce --no-checkout support into porcelain.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-02T22:15:59Z","receivedAt":"2011-08-02T22:15:59Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"git-bisect can now perform bisection of a history without performing\na checkout at each stage of the bisection process. Instead, HEAD is updated.\n\nOne use-case for this function is allow git bisect to be used with\ndamaged repositories where git checkout would fail because the tree\nreferenced by the commit is damaged.\n\nIt can also be used in other cases where actual checkout of the tree\nis not required to progress the bisection.\n\nImproved-by: Christian Couder <chriscool@tuxfamily.org>\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n git-bisect.sh |   32 +++++++++++++++++++++++++-------\n 1 files changed, 25 insertions(+), 7 deletions(-)\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex a44ffe1..99a2637 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -3,7 +3,7 @@\n USAGE='[help|start|bad|good|skip|next|reset|visualize|replay|log|run]'\n LONG_USAGE='git bisect help\n         print this long help message.\n-git bisect start [<bad> [<good>...]] [--] [<pathspec>...]\n+git bisect start [--no-checkout] [<bad> [<good>...]] [--] [<pathspec>...]\n         reset bisect state and start bisection.\n git bisect bad [<rev>]\n         mark <rev> a known-bad revision.\n@@ -34,6 +34,8 @@ require_work_tree\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 \n+BISECT_MODE=$(test -f \"$GIT_DIR/BISECT_MODE\" && cat \"$GIT_DIR/BISECT_MODE\")\n+\n bisect_autostart() {\n \ttest -s \"$GIT_DIR/BISECT_START\" || {\n \t\t(\n@@ -69,6 +71,7 @@ bisect_start() {\n \torig_args=$(git rev-parse --sq-quote \"$@\")\n \tbad_seen=0\n \teval=''\n+\tBISECT_MODE=\n \twhile [ $# -gt 0 ]; do\n \t    arg=\"$1\"\n \t    case \"$arg\" in\n@@ -76,6 +79,11 @@ bisect_start() {\n \t\tshift\n \t\tbreak\n \t\t;;\n+\t    --no-checkout)\n+\t\tBISECT_MODE=--no-checkout;\n+\t\tshift ;;\n+\t    --*)\n+\t\tdie \"$(eval_gettext \"unrecognised option: '\\$arg'\")\" ;;\n \t    *)\n \t\trev=$(git rev-parse -q --verify \"$arg^{commit}\") || {\n \t\t    test $has_double_dash -eq 1 &&\n@@ -107,7 +115,11 @@ bisect_start() {\n \tthen\n \t\t# Reset to the rev from where we started.\n \t\tstart_head=$(cat \"$GIT_DIR/BISECT_START\")\n-\t\tgit checkout \"$start_head\" -- || exit\n+\t\tif test \"$BISECT_MODE\" = \"--no-checkout\"; then\n+\t\t    git update-ref --no-deref HEAD \"$start_head\"\n+\t\telse\n+\t\t    git checkout \"$start_head\" --\n+\t\tfi\n \telse\n \t\t# Get rev from where we start.\n \t\tcase \"$head\" in\n@@ -144,7 +156,8 @@ bisect_start() {\n \t# Write new start state.\n \t#\n \techo \"$start_head\" >\"$GIT_DIR/BISECT_START\" &&\n-\tgit rev-parse --sq-quote \"$@\" >\"$GIT_DIR/BISECT_NAMES\" &&\n+\tgit rev-parse --sq-quote \"$@\" >\"$GIT_DIR/BISECT_NAMES\"\n+\techo \"$BISECT_MODE\" > \"$GIT_DIR/BISECT_MODE\" &&\n \teval \"$eval true\" &&\n \techo \"git bisect start$orig_args\" >>\"$GIT_DIR/BISECT_LOG\" || exit\n \t#\n@@ -291,7 +304,7 @@ bisect_next() {\n \tbisect_next_check good\n \n \t# Perform all bisection computation, display and checkout\n-\tgit bisect--helper --next-all\n+\tgit bisect--helper --next-all ${BISECT_MODE}\n \tres=$?\n \n         # Check if we should exit because bisection is finished\n@@ -340,11 +353,15 @@ bisect_reset() {\n \t*)\n \t    usage ;;\n \tesac\n-\tif git checkout \"$branch\" -- ; then\n-\t\tbisect_clean_state\n+\tif test \"$BISECT_MODE\" = \"--no-checkout\"; then\n+\t\tgit symbolic-ref HEAD $(git rev-parse --symbolic-full-name \"${branch}\")\n \telse\n-\t\tdie \"$(eval_gettext \"Could not check out original HEAD '\\$branch'.\n+\t\tif git checkout \"$branch\" --; then\n+\t\t\tbisect_clean_state\n+\t\telse\n+\t\t\tdie \"$(eval_gettext \"Could not check out original HEAD '\\$branch'.\n Try 'git bisect reset <commit>'.\")\"\n+\t\tfi\n \tfi\n }\n \n@@ -360,6 +377,7 @@ bisect_clean_state() {\n \trm -f \"$GIT_DIR/BISECT_LOG\" &&\n \trm -f \"$GIT_DIR/BISECT_NAMES\" &&\n \trm -f \"$GIT_DIR/BISECT_RUN\" &&\n+\trm -f \"$GIT_DIR/BISECT_MODE\" &&\n \t# Cleanup head-name if it got left by an old version of git-bisect\n \trm -f \"$GIT_DIR/head-name\" &&\n \n-- \n1.7.6.353.gb3ae7e\n"},{"id":"172710","messageId":"1312323362-20096-7-git-send-email-jon.seymour@gmail.com","threadId":"27999","inReplyTo":"1312323362-20096-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v14 6/8] bisect: add tests for the --no-checkout option.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-02T22:16:00Z","receivedAt":"2011-08-02T22:16:00Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"These tests verify that git-bisect --no-checkout can successfully\nbisect commit histories that reference damaged trees.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n t/t6030-bisect-porcelain.sh |   70 +++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 70 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh\nindex 9ae2de8..a1e0ddc 100755\n--- a/t/t6030-bisect-porcelain.sh\n+++ b/t/t6030-bisect-porcelain.sh\n@@ -616,6 +616,14 @@ cat > expected.missing-tree.default <<EOF\n fatal: unable to read tree 39f7e61a724187ab767d2e08442d9b6b9dab587d\n EOF\n \n+check_same()\n+{\n+    echo \"Checking $1 is the same as $2\" &&\n+    git rev-parse \"$1\" > expected.same &&\n+    git rev-parse \"$2\" > expected.actual &&\n+    test_cmp expected.same expected.actual\n+}\n+\n test_expect_success 'bisect fails if tree is broken on start commit' '\n \tgit bisect reset &&\n \ttest_must_fail git bisect start BROKEN_HASH7 BROKEN_HASH4 2>error.txt &&\n@@ -630,4 +638,66 @@ test_expect_success 'bisect fails if tree is broken on trial commit' '\n \ttest_cmp expected.missing-tree.default error.txt\n '\n \n+test_expect_success 'bisect: --no-checkout - start commit bad' '\n+\tgit bisect reset &&\n+\tgit bisect start BROKEN_HASH7 BROKEN_HASH4 --no-checkout &&\n+\tcheck_same BROKEN_HASH6 HEAD &&\n+\tgit bisect reset\n+'\n+\n+test_expect_success 'bisect: --no-checkout - trial commit bad' '\n+\tgit bisect reset &&\n+\tgit bisect start broken BROKEN_HASH4 --no-checkout &&\n+\tcheck_same BROKEN_HASH6 HEAD &&\n+\tgit bisect reset\n+'\n+\n+test_expect_success 'bisect: --no-checkout - target before breakage' '\n+\tgit bisect reset &&\n+\tgit bisect start broken BROKEN_HASH4 --no-checkout &&\n+\tcheck_same BROKEN_HASH6 HEAD &&\n+\tgit bisect bad HEAD &&\n+\tcheck_same BROKEN_HASH5 HEAD &&\n+\tgit bisect bad HEAD &&\n+\tcheck_same BROKEN_HASH5 bisect/bad &&\n+\tgit bisect reset\n+'\n+\n+test_expect_success 'bisect: --no-checkout - target in breakage' '\n+\tgit bisect reset &&\n+\tgit bisect start broken BROKEN_HASH4 --no-checkout &&\n+\tcheck_same BROKEN_HASH6 HEAD &&\n+\tgit bisect bad HEAD &&\n+\tcheck_same BROKEN_HASH5 HEAD &&\n+\tgit bisect good HEAD &&\n+\tcheck_same BROKEN_HASH6 bisect/bad &&\n+\tgit bisect reset\n+'\n+\n+test_expect_success 'bisect: --no-checkout - target after breakage' '\n+\tgit bisect reset &&\n+\tgit bisect start broken BROKEN_HASH4 --no-checkout &&\n+\tcheck_same BROKEN_HASH6 HEAD &&\n+\tgit bisect good HEAD &&\n+\tcheck_same BROKEN_HASH8 HEAD &&\n+\tgit bisect good HEAD &&\n+\tcheck_same BROKEN_HASH9 bisect/bad &&\n+\tgit bisect reset\n+'\n+\n+test_expect_success 'bisect: demonstrate identification of damage boundary' \"\n+\tgit bisect reset &&\n+\tgit checkout broken &&\n+\tgit bisect start broken master --no-checkout &&\n+\tgit bisect run eval '\n+rc=1;\n+if git rev-list --objects HEAD >tmp.$$; then\n+   git pack-objects --stdout >/dev/null < tmp.$$ && rc=0;\n+fi;\n+rm tmp.$$;\n+test \\$rc -eq 0;' &&\n+\tcheck_same BROKEN_HASH6 bisect/bad &&\n+\tgit bisect reset\n+\"\n+\n test_done\n-- \n1.7.6.353.gb3ae7e\n"},{"id":"172713","messageId":"1312323362-20096-8-git-send-email-jon.seymour@gmail.com","threadId":"27999","inReplyTo":"1312323362-20096-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v14 7/8] bisect: add documentation for --no-checkout option.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-02T22:16:01Z","receivedAt":"2011-08-02T22:16:01Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Signed-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n Documentation/git-bisect.txt |   32 +++++++++++++++++++++++++++++++-\n 1 files changed, 31 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt\nindex ab60a18..2014894 100644\n--- a/Documentation/git-bisect.txt\n+++ b/Documentation/git-bisect.txt\n@@ -17,7 +17,7 @@ The command takes various subcommands, and different options depending\n on the subcommand:\n \n  git bisect help\n- git bisect start [<bad> [<good>...]] [--] [<paths>...]\n+ git bisect start [--no-checkout] [<bad> [<good>...]] [--] [<paths>...]\n  git bisect bad [<rev>]\n  git bisect good [<rev>...]\n  git bisect skip [(<rev>|<range>)...]\n@@ -263,6 +263,17 @@ rewind the tree to the pristine state.  Finally the script should exit\n with the status of the real test to let the \"git bisect run\" command loop\n determine the eventual outcome of the bisect session.\n \n+OPTIONS\n+-------\n+--no-checkout::\n++\n+This option is used to specify that 'git bisect' should not modify the working\n+tree or index on each iteration of the bisection process but should\n+update HEAD instead.\n++\n+This option is useful in circumstances in which checkout is either not\n+possible (because of a damaged respository) or is otherwise not required.\n+\n EXAMPLES\n --------\n \n@@ -343,6 +354,25 @@ $ git bisect run sh -c \"make || exit 125; ~/check_test_case.sh\"\n This shows that you can do without a run script if you write the test\n on a single line.\n \n+* Locate a good region of the object graph in a damaged repository\n++\n+------------\n+$ git bisect start HEAD <known-good-commit> [ <boundary-commit> ... ] --no-checkout\n+$ git bisect run eval '\n+rc=1;\n+if git rev-list --objects HEAD >tmp.$$; then\n+   git pack-objects --stdout >/dev/null < tmp.$$ && rc=0;\n+fi;\n+rm tmp.$$;\n+test $rc -eq 0;'\n+\n+------------\n++\n+In this case, when 'git bisect run' finishes, bisect/bad will refer to a commit that\n+has at least one parent whose reachable graph is fully traversable in the sense\n+required by 'git pack objects'.\n+\n+\n SEE ALSO\n --------\n link:git-bisect-lk2009.html[Fighting regressions with git bisect],\n-- \n1.7.6.353.gb3ae7e\n"},{"id":"172714","messageId":"1312323362-20096-9-git-send-email-jon.seymour@gmail.com","threadId":"27999","inReplyTo":"1312323362-20096-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v14 8/8] bisect: change bisect function to update BISECT_HEAD, rather than HEAD.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-02T22:16:02Z","receivedAt":"2011-08-02T22:16:02Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"This function modifies git-bisect so that the --no-checkout option\nuses BISECT_HEAD rather than HEAD to record the current bisection\nhead.\n\nThe intent is to reduce the confusion that uses of --no-checkout\nmay experience when using the --no-checkout option since the bisection\nprocess will no longer introduce spurious differences between the\nHEAD reference and the working tree and index.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n Documentation/git-bisect.txt |    8 ++++----\n bisect.c                     |    2 +-\n builtin/bisect--helper.c     |    2 +-\n git-bisect.sh                |   17 +++++++++++++----\n t/t6030-bisect-porcelain.sh  |   30 +++++++++++++++---------------\n 5 files changed, 34 insertions(+), 25 deletions(-)\n\ndiff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt\nindex 2014894..a9b217b 100644\n--- a/Documentation/git-bisect.txt\n+++ b/Documentation/git-bisect.txt\n@@ -267,9 +267,9 @@ OPTIONS\n -------\n --no-checkout::\n +\n-This option is used to specify that 'git bisect' should not modify the working\n-tree or index on each iteration of the bisection process but should\n-update HEAD instead.\n+This option is used to specify that 'git bisect' should not checkout the\n+new working tree at each iteration of the bisection process but should\n+instead update BISECT_HEAD.\n +\n This option is useful in circumstances in which checkout is either not\n possible (because of a damaged respository) or is otherwise not required.\n@@ -360,7 +360,7 @@ on a single line.\n $ git bisect start HEAD <known-good-commit> [ <boundary-commit> ... ] --no-checkout\n $ git bisect run eval '\n rc=1;\n-if git rev-list --objects HEAD >tmp.$$; then\n+if git rev-list --objects BISECT_HEAD >tmp.$$; then\n    git pack-objects --stdout >/dev/null < tmp.$$ && rc=0;\n fi;\n rm tmp.$$;\ndiff --git a/bisect.c b/bisect.c\nindex 0427117..46874be 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -24,7 +24,7 @@ struct argv_array {\n \n static const char *argv_checkout[] = {\"checkout\", \"-q\", NULL, \"--\", NULL};\n static const char *argv_show_branch[] = {\"show-branch\", NULL, NULL};\n-static const char *argv_update_ref[] = {\"update-ref\", \"--no-deref\", \"HEAD\", NULL, NULL};\n+static const char *argv_update_ref[] = {\"update-ref\", \"--no-deref\", \"BISECT_HEAD\", NULL, NULL};\n \n /* bits #0-15 in revision.h */\n \ndiff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c\nindex d96a193..8d325a5 100644\n--- a/builtin/bisect--helper.c\n+++ b/builtin/bisect--helper.c\n@@ -16,7 +16,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOLEAN(0, \"next-all\", &next_all,\n \t\t\t    \"perform 'git bisect next'\"),\n \t\tOPT_BOOLEAN(0, \"no-checkout\", &no_checkout,\n-\t\t\t    \"update HEAD instead of checking out the current commit\"),\n+\t\t\t    \"update BISECT_HEAD instead of checking out the current commit\"),\n \t\tOPT_END()\n \t};\n \ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 99a2637..9792a84 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -36,6 +36,15 @@ _x40=\"$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40\"\n \n BISECT_MODE=$(test -f \"$GIT_DIR/BISECT_MODE\" && cat \"$GIT_DIR/BISECT_MODE\")\n \n+bisect_head()\n+{\n+    if test \"$BISECT_MODE\" = \"--no-checkout\"; then\n+\techo BISECT_HEAD;\n+    else\n+\techo HEAD\n+    fi\n+}\n+\n bisect_autostart() {\n \ttest -s \"$GIT_DIR/BISECT_START\" || {\n \t\t(\n@@ -116,7 +125,7 @@ bisect_start() {\n \t\t# Reset to the rev from where we started.\n \t\tstart_head=$(cat \"$GIT_DIR/BISECT_START\")\n \t\tif test \"$BISECT_MODE\" = \"--no-checkout\"; then\n-\t\t    git update-ref --no-deref HEAD \"$start_head\"\n+\t\t    git update-ref --no-deref $(bisect_head) \"$start_head\"\n \t\telse\n \t\t    git checkout \"$start_head\" --\n \t\tfi\n@@ -219,8 +228,8 @@ bisect_state() {\n \t0,*)\n \t\tdie \"$(gettext \"Please call 'bisect_state' with at least one argument.\")\" ;;\n \t1,bad|1,good|1,skip)\n-\t\trev=$(git rev-parse --verify HEAD) ||\n-\t\t\tdie \"$(gettext \"Bad rev input: HEAD\")\"\n+\t\trev=$(git rev-parse --verify $(bisect_head)) ||\n+\t\t\tdie \"$(gettext \"Bad rev input: $(bisect_head)\")\"\n \t\tbisect_write \"$state\" \"$rev\"\n \t\tcheck_expected_revs \"$rev\" ;;\n \t2,bad|*,good|*,skip)\n@@ -354,7 +363,7 @@ bisect_reset() {\n \t    usage ;;\n \tesac\n \tif test \"$BISECT_MODE\" = \"--no-checkout\"; then\n-\t\tgit symbolic-ref HEAD $(git rev-parse --symbolic-full-name \"${branch}\")\n+\t\tgit symbolic-ref $(bisect_head) $(git rev-parse --symbolic-full-name \"${branch}\")\n \telse\n \t\tif git checkout \"$branch\" --; then\n \t\t\tbisect_clean_state\ndiff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh\nindex a1e0ddc..ef422a1 100755\n--- a/t/t6030-bisect-porcelain.sh\n+++ b/t/t6030-bisect-porcelain.sh\n@@ -641,24 +641,24 @@ test_expect_success 'bisect fails if tree is broken on trial commit' '\n test_expect_success 'bisect: --no-checkout - start commit bad' '\n \tgit bisect reset &&\n \tgit bisect start BROKEN_HASH7 BROKEN_HASH4 --no-checkout &&\n-\tcheck_same BROKEN_HASH6 HEAD &&\n+\tcheck_same BROKEN_HASH6 BISECT_HEAD &&\n \tgit bisect reset\n '\n \n test_expect_success 'bisect: --no-checkout - trial commit bad' '\n \tgit bisect reset &&\n \tgit bisect start broken BROKEN_HASH4 --no-checkout &&\n-\tcheck_same BROKEN_HASH6 HEAD &&\n+\tcheck_same BROKEN_HASH6 BISECT_HEAD &&\n \tgit bisect reset\n '\n \n test_expect_success 'bisect: --no-checkout - target before breakage' '\n \tgit bisect reset &&\n \tgit bisect start broken BROKEN_HASH4 --no-checkout &&\n-\tcheck_same BROKEN_HASH6 HEAD &&\n-\tgit bisect bad HEAD &&\n-\tcheck_same BROKEN_HASH5 HEAD &&\n-\tgit bisect bad HEAD &&\n+\tcheck_same BROKEN_HASH6 BISECT_HEAD &&\n+\tgit bisect bad BISECT_HEAD &&\n+\tcheck_same BROKEN_HASH5 BISECT_HEAD &&\n+\tgit bisect bad BISECT_HEAD &&\n \tcheck_same BROKEN_HASH5 bisect/bad &&\n \tgit bisect reset\n '\n@@ -666,10 +666,10 @@ test_expect_success 'bisect: --no-checkout - target before breakage' '\n test_expect_success 'bisect: --no-checkout - target in breakage' '\n \tgit bisect reset &&\n \tgit bisect start broken BROKEN_HASH4 --no-checkout &&\n-\tcheck_same BROKEN_HASH6 HEAD &&\n-\tgit bisect bad HEAD &&\n-\tcheck_same BROKEN_HASH5 HEAD &&\n-\tgit bisect good HEAD &&\n+\tcheck_same BROKEN_HASH6 BISECT_HEAD &&\n+\tgit bisect bad BISECT_HEAD &&\n+\tcheck_same BROKEN_HASH5 BISECT_HEAD &&\n+\tgit bisect good BISECT_HEAD &&\n \tcheck_same BROKEN_HASH6 bisect/bad &&\n \tgit bisect reset\n '\n@@ -677,10 +677,10 @@ test_expect_success 'bisect: --no-checkout - target in breakage' '\n test_expect_success 'bisect: --no-checkout - target after breakage' '\n \tgit bisect reset &&\n \tgit bisect start broken BROKEN_HASH4 --no-checkout &&\n-\tcheck_same BROKEN_HASH6 HEAD &&\n-\tgit bisect good HEAD &&\n-\tcheck_same BROKEN_HASH8 HEAD &&\n-\tgit bisect good HEAD &&\n+\tcheck_same BROKEN_HASH6 BISECT_HEAD &&\n+\tgit bisect good BISECT_HEAD &&\n+\tcheck_same BROKEN_HASH8 BISECT_HEAD &&\n+\tgit bisect good BISECT_HEAD &&\n \tcheck_same BROKEN_HASH9 bisect/bad &&\n \tgit bisect reset\n '\n@@ -691,7 +691,7 @@ test_expect_success 'bisect: demonstrate identification of damage boundary' \"\n \tgit bisect start broken master --no-checkout &&\n \tgit bisect run eval '\n rc=1;\n-if git rev-list --objects HEAD >tmp.$$; then\n+if git rev-list --objects BISECT_HEAD >tmp.$$; then\n    git pack-objects --stdout >/dev/null < tmp.$$ && rc=0;\n fi;\n rm tmp.$$;\n-- \n1.7.6.353.gb3ae7e\n"},{"id":"172718","messageId":"7voc07ct9z.fsf@alter.siamese.dyndns.org","threadId":"27999","inReplyTo":"1312323362-20096-6-git-send-email-jon.seymour@gmail.com","subject":"Re: [PATCH v14 5/8] bisect: introduce --no-checkout support into porcelain.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-08-02T23:01:28Z","receivedAt":"2011-08-02T23:01:28Z","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> +\tBISECT_MODE=\n>  \twhile [ $# -gt 0 ]; do\n>  \t    arg=\"$1\"\n>  \t    case \"$arg\" in\n> @@ -76,6 +79,11 @@ bisect_start() {\n>  \t\tshift\n>  \t\tbreak\n>  \t\t;;\n> +\t    --no-checkout)\n> +\t\tBISECT_MODE=--no-checkout;\n> +\t\tshift ;;\n> +\t    --*)\n> +\t\tdie \"$(eval_gettext \"unrecognised option: '\\$arg'\")\" ;;\n>  \t    *)\n>  \t\trev=$(git rev-parse -q --verify \"$arg^{commit}\") || {\n>  \t\t    test $has_double_dash -eq 1 &&\n> @@ -107,7 +115,11 @@ bisect_start() {\n>  \tthen\n>  \t\t# Reset to the rev from where we started.\n>  \t\tstart_head=$(cat \"$GIT_DIR/BISECT_START\")\n> -\t\tgit checkout \"$start_head\" -- || exit\n> +\t\tif test \"$BISECT_MODE\" = \"--no-checkout\"; then\n> +\t\t    git update-ref --no-deref HEAD \"$start_head\"\n> +\t\telse\n> +\t\t    git checkout \"$start_head\" --\n> +\t\tfi\n\nJust a minor worry but I would not be surprised if somebody's \"test\"\nimplementation barfs upon:\n\n\ttest \"--no-checkout\" = \"--no-checkout\"\n\nmistaking the string with a dash at the beginning as an option unknown to\nit. That is why we often have \"z$variable\" in our comparison, like so:\n\n\tif test \"z$BISECT_MODE\" = \"z--no-checkout\"\n        then\n        \tgit update-ref --no-deref BISECT_HEAD \"$start_head\"\n\telse\n        \tgit checkout \"$start_head\" --\n\tfi\n\n> -\tgit rev-parse --sq-quote \"$@\" >\"$GIT_DIR/BISECT_NAMES\" &&\n> +\tgit rev-parse --sq-quote \"$@\" >\"$GIT_DIR/BISECT_NAMES\"\n> +\techo \"$BISECT_MODE\" > \"$GIT_DIR/BISECT_MODE\" &&\n\n&&?\n"},{"id":"172719","messageId":"7vk4avcsk9.fsf@alter.siamese.dyndns.org","threadId":"27999","inReplyTo":"7voc07ct9z.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v14 5/8] bisect: introduce --no-checkout support into porcelain.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-08-02T23:16:54Z","receivedAt":"2011-08-02T23:16:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Jon Seymour <jon.seymour@gmail.com> writes:\n> ...\n>> +\t\tif test \"$BISECT_MODE\" = \"--no-checkout\"; then\n>> +\t\t    git update-ref --no-deref HEAD \"$start_head\"\n>> +\t\telse\n>> +\t\t    git checkout \"$start_head\" --\n>> +\t\tfi\n>\n> Just a minor worry but I would not be surprised if somebody's \"test\"\n> implementation barfs upon:\n>\n> \ttest \"--no-checkout\" = \"--no-checkout\"\n>\n> mistaking the string with a dash at the beginning as an option unknown to\n> it. That is why we often have \"z$variable\" in our comparison, like so:\n>\n> \tif test \"z$BISECT_MODE\" = \"z--no-checkout\"\n>         then\n>         \tgit update-ref --no-deref BISECT_HEAD \"$start_head\"\n> \telse\n>         \tgit checkout \"$start_head\" --\n> \tfi\n>\n>> -\tgit rev-parse --sq-quote \"$@\" >\"$GIT_DIR/BISECT_NAMES\" &&\n>> +\tgit rev-parse --sq-quote \"$@\" >\"$GIT_DIR/BISECT_NAMES\"\n>> +\techo \"$BISECT_MODE\" > \"$GIT_DIR/BISECT_MODE\" &&\n>\n> &&?\n\nHaving said that, other than these minor nits, I think this round is\nalmost ready. I didn't check how it behaves upon \"bisect reset\",\nthough. It shouldn't touch the index, HEAD nor the working tree (it\nprobably is just the matter of \"update-ref -d BISECT_HEAD\" and nothing\nelse, but I haven't thought things through thoroughly).\n\nFurther polishing we may want to do while it is still in pu/next I can\nthink of off the top of my head are:\n\n - In this mode, I can bisect the history even inside a bare repository,\n   as the whole point of --no-checkout is that the mode does not require a\n   working tree. I however suspect \"git bisect\" requires working tree. Is\n   this something we want to fix?\n\n - Further, perhaps should we default to this mode inside a bare\n   repository?\n\nChristian, do you think of anything else?  Also do you see flaws in our\nreasoning that updating only BISECT_HEAD and doing nothing else is a good\nway to do this?\n"},{"id":"172726","messageId":"201108030643.09014.chriscool@tuxfamily.org","threadId":"27999","inReplyTo":"1312323362-20096-9-git-send-email-jon.seymour@gmail.com","subject":"Re: [PATCH v14 8/8] bisect: change bisect function to update BISECT_HEAD, rather than HEAD.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2011-08-03T04:43:08Z","receivedAt":"2011-08-03T04:43:08Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"I think a better title for this patch would be something like:\n\nbisect: update BISECT_HEAD, rather than HEAD, when using --no-checkout\n\nBut anyway in my opinion the patch series would be better if this patch was \nsquashed into the previous patches.\n\nOn Wednesday 03 August 2011 00:16:02 Jon Seymour wrote:\n> This function modifies git-bisect so that the --no-checkout option\n> uses BISECT_HEAD rather than HEAD to record the current bisection\n> head.\n\ns/This function/This patch/\n \n> The intent is to reduce the confusion that uses of --no-checkout\n\ns/uses/users/\n\n> may experience when using the --no-checkout option since the bisection\n> process will no longer introduce spurious differences between the\n> HEAD reference and the working tree and index.\n> \n> Signed-off-by: Jon Seymour <jon.seymour@gmail.com>\n> ---\n>  Documentation/git-bisect.txt |    8 ++++----\n>  bisect.c                     |    2 +-\n>  builtin/bisect--helper.c     |    2 +-\n>  git-bisect.sh                |   17 +++++++++++++----\n>  t/t6030-bisect-porcelain.sh  |   30 +++++++++++++++---------------\n>  5 files changed, 34 insertions(+), 25 deletions(-)\n> \n> diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt\n> index 2014894..a9b217b 100644\n> --- a/Documentation/git-bisect.txt\n> +++ b/Documentation/git-bisect.txt\n> @@ -267,9 +267,9 @@ OPTIONS\n>  -------\n>  --no-checkout::\n>  +\n> -This option is used to specify that 'git bisect' should not modify the\n> working -tree or index on each iteration of the bisection process but\n> should -update HEAD instead.\n> +This option is used to specify that 'git bisect' should not checkout the\n> +new working tree at each iteration of the bisection process but should\n> +instead update BISECT_HEAD.\n\nI would say something like:\n\nDo not checkout the new working tree at each iteration of the bisection \nprocess. Instead just update a special reference named 'BISECT_HEAD' to make \nit point to the commit that should be tested.\n\n>  +\n>  This option is useful in circumstances in which checkout is either not\n>  possible (because of a damaged respository) or is otherwise not required.\n\nThanks,\nChristian.\n"},{"id":"172727","messageId":"201108030717.46817.chriscool@tuxfamily.org","threadId":"27999","inReplyTo":"1312323362-20096-6-git-send-email-jon.seymour@gmail.com","subject":"Re: [PATCH v14 5/8] bisect: introduce --no-checkout support into porcelain.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2011-08-03T05:17:46Z","receivedAt":"2011-08-03T05:17:46Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Wednesday 03 August 2011 00:15:59 Jon Seymour wrote:\n> @@ -291,7 +304,7 @@ bisect_next() {\n>  \tbisect_next_check good\n> \n>  \t# Perform all bisection computation, display and checkout\n> -\tgit bisect--helper --next-all\n> +\tgit bisect--helper --next-all ${BISECT_MODE}\n\nStyle, please use $BISECT_MODE instead of ${BISECT_MODE}\n\nThanks,\nChristian.\n"},{"id":"172730","messageId":"201108030728.42453.chriscool@tuxfamily.org","threadId":"27999","inReplyTo":"7vk4avcsk9.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v14 5/8] bisect: introduce --no-checkout support into porcelain.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2011-08-03T05:28:42Z","receivedAt":"2011-08-03T05:28:42Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Wednesday 03 August 2011 01:16:54 Junio C Hamano wrote:\n> \n> Having said that, other than these minor nits, I think this round is\n> almost ready. I didn't check how it behaves upon \"bisect reset\",\n> though. It shouldn't touch the index, HEAD nor the working tree (it\n> probably is just the matter of \"update-ref -d BISECT_HEAD\" and nothing\n> else, but I haven't thought things through thoroughly).\n> \n> Further polishing we may want to do while it is still in pu/next I can\n> think of off the top of my head are:\n> \n>  - In this mode, I can bisect the history even inside a bare repository,\n>    as the whole point of --no-checkout is that the mode does not require a\n>    working tree. I however suspect \"git bisect\" requires working tree. Is\n>    this something we want to fix?\n> \n>  - Further, perhaps should we default to this mode inside a bare\n>    repository?\n\nI agree that it would be nice if it worked in a bare repo. I did not look at \nthat yet.\n\n> Christian, do you think of anything else?\n\nNo, I agree that it looks almost ready.\n\nThe few improvements I would like are:\n\n- squashing the last patch into the previous ones,\n- using a bisect_mode() function when needed.\n\n> Also do you see flaws in our\n> reasoning that updating only BISECT_HEAD and doing nothing else is a good\n> way to do this?\n\nNo, I agree that --no-checkout is a good idea and that using only BISECT_HEAD \nis good way to do this.\n\nThanks,\nChristian.\n"},{"id":"172753","messageId":"CAH3AnrrtfhU1r1DWO8ski5Jd=cLXcj3Wq-MowB8QKv+r1-BT_A@mail.gmail.com","threadId":"27999","inReplyTo":"7vk4avcsk9.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v14 5/8] bisect: introduce --no-checkout support into porcelain.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-03T13:16:15Z","receivedAt":"2011-08-03T13:16:15Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"On Wed, Aug 3, 2011 at 9:16 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> Jon Seymour <jon.seymour@gmail.com> writes:\n>> ...\n>>> +            if test \"$BISECT_MODE\" = \"--no-checkout\"; then\n>>> +                git update-ref --no-deref HEAD \"$start_head\"\n>>> +            else\n>>> +                git checkout \"$start_head\" --\n>>> +            fi\n>>\n>> Just a minor worry but I would not be surprised if somebody's \"test\"\n>> implementation barfs upon:\n>>\n>>       test \"--no-checkout\" = \"--no-checkout\"\n>>\n>> mistaking the string with a dash at the beginning as an option unknown to\n>> it. That is why we often have \"z$variable\" in our comparison, like so:\n>>\n>>       if test \"z$BISECT_MODE\" = \"z--no-checkout\"\n>>         then\n>>               git update-ref --no-deref BISECT_HEAD \"$start_head\"\n>>       else\n>>               git checkout \"$start_head\" --\n>>       fi\n>>\n>>> -    git rev-parse --sq-quote \"$@\" >\"$GIT_DIR/BISECT_NAMES\" &&\n>>> +    git rev-parse --sq-quote \"$@\" >\"$GIT_DIR/BISECT_NAMES\"\n>>> +    echo \"$BISECT_MODE\" > \"$GIT_DIR/BISECT_MODE\" &&\n>>\n>> &&?\n>\n> Having said that, other than these minor nits, I think this round is\n> almost ready. I didn't check how it behaves upon \"bisect reset\",\n> though. It shouldn't touch the index, HEAD nor the working tree (it\n> probably is just the matter of \"update-ref -d BISECT_HEAD\" and nothing\n> else, but I haven't thought things through thoroughly).\n\nThat seems reasonable. In fact, none of these series properly cleaned\nup the reset state properly, so I'll fix that and a test for it.\n\n>\n> Further polishing we may want to do while it is still in pu/next I can\n> think of off the top of my head are:\n>\n>  - In this mode, I can bisect the history even inside a bare repository,\n>   as the whole point of --no-checkout is that the mode does not require a\n>   working tree. I however suspect \"git bisect\" requires working tree. Is\n>   this something we want to fix?\n>\n\nI agree, that would be useful. Haven't tried it yet but I'll see what\nhappens.I may issue changes for this as separate commit that can be\nsquashed later, if required,  once it has been reviewed.\n\nBTW: I'll squash v14 8/8 into the other commits, per Christian's suggestion.\n\n>  - Further, perhaps should we default to this mode inside a bare\n>   repository?\n\nSeems reasonable.\n\njon.\n"},{"id":"172777","messageId":"CAH3AnrpPaUY1fj9thMybPUgeM=mBEN3FjawjiR2vhw4S-v6qyg@mail.gmail.com","threadId":"27999","inReplyTo":"CAH3AnrrtfhU1r1DWO8ski5Jd=cLXcj3Wq-MowB8QKv+r1-BT_A@mail.gmail.com","subject":"Re: [PATCH v14 5/8] bisect: introduce --no-checkout support into porcelain.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-03T15:24:12Z","receivedAt":"2011-08-03T15:24:12Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"On Wed, Aug 3, 2011 at 11:16 PM, Jon Seymour <jon.seymour@gmail.com> wrote:\n> On Wed, Aug 3, 2011 at 9:16 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>> Junio C Hamano <gitster@pobox.com> writes:\n>>\n>>> Jon Seymour <jon.seymour@gmail.com> writes:\n\n>>\n>> Further polishing we may want to do while it is still in pu/next I can\n>> think of off the top of my head are:\n>>\n>>  - In this mode, I can bisect the history even inside a bare repository,\n>>   as the whole point of --no-checkout is that the mode does not require a\n>>   working tree. I however suspect \"git bisect\" requires working tree. Is\n>>   this something we want to fix?\n>>\n>\n> I agree, that would be useful. Haven't tried it yet but I'll see what\n> happens.I may issue changes for this as separate commit that can be\n> squashed later, if required,  once it has been reviewed.\n>\n\nI had a quick go at doing this, but haven't been able to test it\nfully. At a minimum it will require that we relax the barriers in\ngit-bisect.sh and git.c that prevent git-bisect\nand bisect--helper running without a working tree. Other paths in\nthese modules will need to  be checked to see that they don't have an\nimplicit assumption that a  working tree is available.\n\nI  won't have time to tackle this properly until the weekend.\n\njon.\n"},{"id":"172782","messageId":"7vd3gmcttn.fsf@alter.siamese.dyndns.org","threadId":"27999","inReplyTo":"CAH3AnrpPaUY1fj9thMybPUgeM=mBEN3FjawjiR2vhw4S-v6qyg@mail.gmail.com","subject":"Re: [PATCH v14 5/8] bisect: introduce --no-checkout support into porcelain.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-08-03T17:01:56Z","receivedAt":"2011-08-03T17:01:56Z","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> I had a quick go at doing this, but haven't been able to test it\n> fully. At a minimum it will require that we relax the barriers in\n> git-bisect.sh and git.c that prevent git-bisect\n> and bisect--helper running without a working tree. Other paths in\n> these modules will need to  be checked to see that they don't have an\n> implicit assumption that a  working tree is available.\n>\n> I  won't have time to tackle this properly until the weekend.\n\nThat is Ok and thanks for looking. Making this available to bare\nrepository is a totally separate follow-on topic that can and should be\ndone as a separate series that depends on the current topic anyway, so\nlet's focus on the current topic at hand first.\n"},{"id":"172792","messageId":"20110803185719.GA4275@elie.Hillsp","threadId":"27999","inReplyTo":"7voc07ct9z.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v14 5/8] bisect: introduce --no-checkout support into porcelain.","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-08-03T18:57:19Z","receivedAt":"2011-08-03T18:57:19Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n\n> Just a minor worry but I would not be surprised if somebody's \"test\"\n> implementation barfs upon:\n>\n> \ttest \"--no-checkout\" = \"--no-checkout\"\n>\n> mistaking the string with a dash at the beginning as an option unknown to\n> it. That is why we often have \"z$variable\" in our comparison, like so:\n>\n> \tif test \"z$BISECT_MODE\" = \"z--no-checkout\"\n\nHmm.\n\n\t$ git grep -e 'test \"\\$' | wc -l\n\t712\n\t$ git grep -e 'test \".\\$' | wc -l\n\t183\n\nWe are very inconsistent about such usage, generally, and of course\nPOSIX is very clear about the 'z' not being needed in a three-argument\n\"test\" used for string comparison.  Is there any platform that is\nusable for git (e.g., that implements \"$( ... )\") and has that\nproblem?\n"},{"id":"172809","messageId":"CAH3AnrrMUiWkRk0ocr4RY05qj7GU5hqSkaxy+zYJRx12o=hwNA@mail.gmail.com","threadId":"27999","inReplyTo":"20110803185719.GA4275@elie.Hillsp","subject":"Re: [PATCH v14 5/8] bisect: introduce --no-checkout support into porcelain.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-03T21:40:12Z","receivedAt":"2011-08-03T21:40:12Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"On Thu, Aug 4, 2011 at 4:57 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Junio C Hamano wrote:\n>\n>> Just a minor worry but I would not be surprised if somebody's \"test\"\n>> implementation barfs upon:\n>>\n>>       test \"--no-checkout\" = \"--no-checkout\"\n>>\n>> mistaking the string with a dash at the beginning as an option unknown to\n>> it. That is why we often have \"z$variable\" in our comparison, like so:\n>>\n>>       if test \"z$BISECT_MODE\" = \"z--no-checkout\"\n>\n> Hmm.\n>\n>        $ git grep -e 'test \"\\$' | wc -l\n>        712\n>        $ git grep -e 'test \".\\$' | wc -l\n>        183\n>\n> We are very inconsistent about such usage, generally, and of course\n> POSIX is very clear about the 'z' not being needed in a three-argument\n> \"test\" used for string comparison.  Is there any platform that is\n> usable for git (e.g., that implements \"$( ... )\") and has that\n> problem?\n>\n\nThanks. Applied.\n"},{"id":"172811","messageId":"20110803214506.GA6740@elie.Hillsp","threadId":"27999","inReplyTo":"CAH3AnrrMUiWkRk0ocr4RY05qj7GU5hqSkaxy+zYJRx12o=hwNA@mail.gmail.com","subject":"Re: [PATCH v14 5/8] bisect: introduce --no-checkout support into porcelain.","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-08-03T21:45:06Z","receivedAt":"2011-08-03T21:45:06Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Jon Seymour wrote:\n> On Thu, Aug 4, 2011 at 4:57 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n\n>> We are very inconsistent about such usage, generally, and of course\n>> POSIX is very clear about the 'z' not being needed in a three-argument\n>> \"test\" used for string comparison.  Is there any platform that is\n>> usable for git (e.g., that implements \"$( ... )\") and has that\n>> problem?\n>\n> Thanks. Applied.\n\nHm --- I was just asking a question, not meant to be rhetorical.  I\nguess the question was applied, or that you inferred some patch from\nit. :)\n"}]}