{"thread":{"id":"27968","subject":"[PATCH v8 0/7] bisect: Add support for --no-checkout and --update-ref=<ref> options.","startedAt":"2011-07-31T11:55:14Z","lastAt":"2011-07-31T21:11:35Z","messageCount":17,"participants":["Jon Seymour","Christian Couder"],"isPatch":true,"patchVersion":8,"patchTotal":7},"messages":[{"id":"172430","messageId":"1312113321-28760-1-git-send-email-jon.seymour@gmail.com","threadId":"27968","inReplyTo":null,"subject":"[PATCH v8 0/7] bisect: Add support for --no-checkout and --update-ref=<ref> options.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-31T11:55:14Z","receivedAt":"2011-07-31T11:55:14Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"For some bisection tasks, checking out the commit at each stage of the bisection process is unecessary or undesirable.\n\nThis series adds support for --no-checkout and --update-ref=<ref> options 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. An alternative reference to update may be specified with --update-ref=<ref>.\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 run eval '\n\t\trc=1;\n\t\tif git rev-list --objects 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\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\nPLEASE NOTE: the initial patch in this series \"bisect: move argument parsing before state modification.\" 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.\n\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\nAlso pushed to github:\n\thttps://github.com/jonseymour/git/commits/no-checkout-v8\n\tgit://github.com/jonseymour/git.git refs/tags/no-checkout-v8:refs/tags/no-checkout-v8\n\n\nJon Seymour (7):\n  bisect: move argument parsing before state modification.\n  bisect: add tests to document expected behaviour in presence of\n    broken trees.\n  bisect: introduce support for --update-ref=<ref> option.\n  bisect: introduce --no-checkout, --update-ref=<ref> support into\n    porcelain.\n  bisect: add tests for the --no-checkout and --update-ref options.\n  bisect: add documentation for --no-checkout and --update-ref=<ref>\n    options.\n  bisect: support --update-ref <ref>\n\n Documentation/git-bisect.txt |   34 ++++++++-\n bisect.c                     |   34 ++++++---\n bisect.h                     |    2 +-\n builtin/bisect--helper.c     |    7 +-\n git-bisect.sh                |  109 +++++++++++++++++----------\n t/t6030-bisect-porcelain.sh  |  168 +++++++++++++++++++++++++++++++++++++++++-\n 6 files changed, 296 insertions(+), 58 deletions(-)\n\n-- \n1.7.6.391.g168d0.dirty\n"},{"id":"172431","messageId":"1312113321-28760-2-git-send-email-jon.seymour@gmail.com","threadId":"27968","inReplyTo":"1312113321-28760-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v8 1/7] bisect: move argument parsing before state modification.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-31T11:55:15Z","receivedAt":"2011-07-31T11:55:15Z","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.391.g168d0.dirty\n"},{"id":"172432","messageId":"1312113321-28760-3-git-send-email-jon.seymour@gmail.com","threadId":"27968","inReplyTo":"1312113321-28760-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v8 2/7] bisect: add tests to document expected behaviour in presence of broken trees.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-31T11:55:16Z","receivedAt":"2011-07-31T11:55:16Z","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.391.g168d0.dirty\n"},{"id":"172433","messageId":"1312113321-28760-4-git-send-email-jon.seymour@gmail.com","threadId":"27968","inReplyTo":"1312113321-28760-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v8 3/7] bisect: introduce support for --update-ref=<ref> option.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-31T11:55:17Z","receivedAt":"2011-07-31T11:55:17Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"If --update-ref=<ref> is specified, then the bisection process uses:\n\n\tgit update-ref --no-deref <ref> <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                 |   34 +++++++++++++++++++++++-----------\n bisect.h                 |    2 +-\n builtin/bisect--helper.c |    7 +++++--\n 3 files changed, 29 insertions(+), 14 deletions(-)\n\ndiff --git a/bisect.c b/bisect.c\nindex dd7e8ed..4291935 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\", NULL, 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, const char *update_ref)\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 (!update_ref) {\n+\t  res = run_command_v_opt(argv_checkout, RUN_GIT_CMD);\n+\t  if (res)\n+\t    exit(res);\n+\t} else {\n+\t    argv_update_ref[2] = update_ref;\n+\t    argv_update_ref[3] = bisect_rev_hex;\n+\t    if (run_command_v_opt(argv_update_ref, RUN_GIT_CMD))\n+\t      die(\"update-ref --no-deref %s failed on %s\", update_ref, bisect_rev_hex);\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(const char *update_ref)\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), update_ref));\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, const char *update_ref)\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(update_ref);\n \n \t/* Create file BISECT_ANCESTORS_OK. */\n \tfd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600);\n@@ -908,8 +916,12 @@ 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 update_ref is not null, the bisection process does not\n+ * checkout the trial commit but instead simply updates the\n+ * specified reference.\n  */\n-int bisect_next_all(const char *prefix)\n+int bisect_next_all(const char *prefix, const char *update_ref)\n {\n \tstruct rev_info revs;\n \tstruct commit_list *tried;\n@@ -920,7 +932,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, update_ref);\n \n \tbisect_rev_setup(&revs, prefix, \"%s\", \"^%s\", 1);\n \trevs.limited = 1;\n@@ -966,6 +978,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, update_ref);\n }\n \ndiff --git a/bisect.h b/bisect.h\nindex 0862ce5..63f0ca5 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, const char *update_ref);\n \n extern int estimate_bisect_steps(int all);\n \ndiff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c\nindex 5b22639..cb13cb2 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 [--update-ref=<ref>]\",\n \tNULL\n };\n \n int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n {\n \tint next_all = 0;\n+\tchar *update_ref = NULL;\n \tstruct option options[] = {\n \t\tOPT_BOOLEAN(0, \"next-all\", &next_all,\n \t\t\t    \"perform 'git bisect next'\"),\n+\t\tOPT_STRING(0, \"update-ref\", &update_ref, \"ref\",\n+\t\t\t    \"update <ref> 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, update_ref);\n }\n-- \n1.7.6.391.g168d0.dirty\n"},{"id":"172434","messageId":"1312113321-28760-5-git-send-email-jon.seymour@gmail.com","threadId":"27968","inReplyTo":"1312113321-28760-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v8 4/7] bisect: introduce --no-checkout, --update-ref=<ref> support into porcelain.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-31T11:55:18Z","receivedAt":"2011-07-31T11:55:18Z","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.\n\nInstead, the reference specified by <ref> is updated. If <ref> is not\nspecified, HEAD is used instead.\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 |   40 ++++++++++++++++++++++++++++++----------\n 1 files changed, 30 insertions(+), 10 deletions(-)\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 20f6dd5..24ac859 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|--update-ref=<ref>] [<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_UPDATE_REF=$(test -f \"$GIT_DIR/BISECT_UPDATE_REF\" && cat \"$GIT_DIR/BISECT_UPDATE_REF\")\n+\n bisect_autostart() {\n \ttest -s \"$GIT_DIR/BISECT_START\" || {\n \t\t(\n@@ -69,13 +71,18 @@ bisect_start() {\n \torig_args=$(git rev-parse --sq-quote \"$@\")\n \tbad_seen=0\n \teval=''\n+\tBISECT_UPDATE_REF=\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\tshift; break ;;\n+\t    --no-checkout)\n+\t\tBISECT_UPDATE_REF=HEAD; shift ;;\n+\t    --update-ref=*)\n+\t\tBISECT_UPDATE_REF=${arg#--update-ref=}; shift ;;\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@@ -92,6 +99,10 @@ bisect_start() {\n \t    esac\n \tdone\n \n+\tif test -n \"$BISECT_UPDATE_REF\"; then\n+\t    eval=\"$eval echo '$BISECT_UPDATE_REF' > '$GIT_DIR/BISECT_UPDATE_REF';\"\n+\tfi\n+\n \t#\n \t# Verify HEAD.\n \t#\n@@ -107,7 +118,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 -z \"$BISECT_UPDATE_REF\"; then\n+\t\t    git checkout \"$start_head\" --\n+\t\telse\n+\t\t    git update-ref --no-deref \"$BISECT_UPDATE_REF\" \"$start_head\"\n+\t\tfi\n \telse\n \t\t# Get rev from where we start.\n \t\tcase \"$head\" in\n@@ -291,7 +306,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_UPDATE_REF:+--update-ref=}$BISECT_UPDATE_REF\n \tres=$?\n \n         # Check if we should exit because bisection is finished\n@@ -340,11 +355,15 @@ bisect_reset() {\n \t*)\n \t    usage ;;\n \tesac\n-\tif git checkout \"$branch\" -- ; then\n-\t\tbisect_clean_state\n-\telse\n-\t\tdie \"$(eval_gettext \"Could not check out original HEAD '\\$branch'.\n+\tif test -z \"$BISECT_UPDATE_REF\"; then\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+\telse\n+\t    git symbolic-ref \"$BISECT_UPDATE_REF\" $(git rev-parse --symbolic-full-name \"${branch}\")\n \tfi\n }\n \n@@ -360,6 +379,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_UPDATE_REF\" &&\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.391.g168d0.dirty\n"},{"id":"172435","messageId":"1312113321-28760-6-git-send-email-jon.seymour@gmail.com","threadId":"27968","inReplyTo":"1312113321-28760-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v8 5/7] bisect: add tests for the --no-checkout and --update-ref options.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-31T11:55:19Z","receivedAt":"2011-07-31T11:55:19Z","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 |   90 +++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 90 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh\nindex 9ae2de8..69d77fa 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,86 @@ 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: --no-checkout --update-ref=CURSOR - check HEAD is unmodified' '\n+\tgit bisect reset &&\n+\tgit checkout broken &&\n+\tBROKEN=$(git rev-parse broken) &&\n+\tgit bisect start broken BROKEN_HASH4 --no-checkout --update-ref=CURSOR &&\n+\tcheck_same CURSOR BROKEN_HASH6 &&\n+\ttest \"refs/heads/broken\" = \"$(git rev-parse --symbolic-full-name HEAD)\" &&\n+\tgit bisect bad CURSOR &&\n+\ttest \"refs/heads/broken\" = \"$(git rev-parse --symbolic-full-name HEAD)\" &&\n+\tcheck_same CURSOR BROKEN_HASH5 &&\n+\ttest \"refs/heads/broken\" = \"$(git rev-parse --symbolic-full-name HEAD)\" &&\n+\tgit bisect good CURSOR &&\n+\tcheck_same BROKEN_HASH6 bisect/bad &&\n+\ttest \"refs/heads/broken\" = \"$(git rev-parse --symbolic-full-name HEAD)\" &&\n+\tgit bisect reset &&\n+\ttest \"refs/heads/broken\" = \"$(git rev-parse --symbolic-full-name HEAD)\" &&\n+\tcheck_same HEAD broken &&\n+\tcheck_same broken $BROKEN\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.391.g168d0.dirty\n"},{"id":"172436","messageId":"1312113321-28760-7-git-send-email-jon.seymour@gmail.com","threadId":"27968","inReplyTo":"1312113321-28760-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v8 6/7] bisect: add documentation for --no-checkout and --update-ref=<ref> options.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-31T11:55:20Z","receivedAt":"2011-07-31T11:55:20Z","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 |   34 +++++++++++++++++++++++++++++++++-\n 1 files changed, 33 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt\nindex ab60a18..25a25b3 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|--update-ref=<ref>] [<bad> [<good>...]] [--] [<paths>...]\n  git bisect bad [<rev>]\n  git bisect good [<rev>...]\n  git bisect skip [(<rev>|<range>)...]\n@@ -263,6 +263,21 @@ 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 a synonym for --update-ref=HEAD.\n+\n+--update-ref=<ref>::\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 the reference specified by <ref> 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 +358,23 @@ $ 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> [ <missing-or-damaged-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 which is fully reachable in the sense of 'git pack-objects'.\n+\n SEE ALSO\n --------\n link:git-bisect-lk2009.html[Fighting regressions with git bisect],\n-- \n1.7.6.391.g168d0.dirty\n"},{"id":"172437","messageId":"1312113321-28760-8-git-send-email-jon.seymour@gmail.com","threadId":"27968","inReplyTo":"1312113321-28760-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v8 7/7] bisect: support --update-ref <ref>","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-31T11:55:21Z","receivedAt":"2011-07-31T11:55:21Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Adds sugar to allow --update-ref=<ref> to be expressed as\n--update-ref <ref> instead.\n\nSuggested-by: Christian Couder <chriscool@tuxfamily.org>\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n git-bisect.sh               |   13 +++++++++++--\n t/t6030-bisect-porcelain.sh |   16 ++++++++++++++++\n 2 files changed, 27 insertions(+), 2 deletions(-)\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 24ac859..ec70cd2 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -79,8 +79,17 @@ bisect_start() {\n \t\tshift; break ;;\n \t    --no-checkout)\n \t\tBISECT_UPDATE_REF=HEAD; shift ;;\n-\t    --update-ref=*)\n-\t\tBISECT_UPDATE_REF=${arg#--update-ref=}; shift ;;\n+\t    --update-ref*)\n+\t\tcase \"$#,$arg\" in\n+\t\t*,*=*)\n+\t\t\tBISECT_UPDATE_REF=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\n+\t\t;;\n+\t\t1,*)\n+\t\t\tusage ;;\n+\t\t*)\n+\t\t\tBISECT_UPDATE_REF=\"$2\";\tshift ;;\n+\t\tesac\n+\t\tshift ;;\n \t    --*)\n \t\tdie \"$(eval_gettext \"unrecognised option: '\\$arg'\")\" ;;\n \t    *)\ndiff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh\nindex 69d77fa..fa4366f 100755\n--- a/t/t6030-bisect-porcelain.sh\n+++ b/t/t6030-bisect-porcelain.sh\n@@ -705,6 +705,22 @@ test_expect_success 'bisect: --no-checkout --update-ref=CURSOR - check HEAD is u\n \tcheck_same broken $BROKEN\n '\n \n+test_expect_success 'bisect: --no-checkout --update-ref CURSOR' '\n+\tgit bisect reset &&\n+\tgit checkout broken &&\n+\tBROKEN=$(git rev-parse broken) &&\n+\tgit bisect start broken BROKEN_HASH4 --no-checkout --update-ref CURSOR &&\n+\tcheck_same CURSOR BROKEN_HASH6 &&\n+\ttest \"refs/heads/broken\" = \"$(git rev-parse --symbolic-full-name HEAD)\"\n+'\n+\n+test_expect_success 'bisect: --no-checkout --update-ref -> fails' '\n+\tgit bisect reset &&\n+\tgit checkout broken &&\n+\tBROKEN=$(git rev-parse broken) &&\n+\ttest_must_fail git bisect start broken BROKEN_HASH4 --no-checkout --update-ref\n+'\n+\n test_expect_success 'bisect: demonstrate identification of damage boundary' \"\n \tgit bisect reset &&\n \tgit checkout broken &&\n-- \n1.7.6.391.g168d0.dirty\n"},{"id":"172441","messageId":"CAH3AnroWm-BU1svjJqK3WzoNknWk495AJ0mxwWMq+1sgAxxnPg@mail.gmail.com","threadId":"27968","inReplyTo":"1312113321-28760-1-git-send-email-jon.seymour@gmail.com","subject":"Re: [PATCH v8 0/7] bisect: Add support for --no-checkout and --update-ref=<ref> options.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-31T13:26:18Z","receivedAt":"2011-07-31T13:26:18Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"On Sun, Jul 31, 2011 at 9:55 PM, Jon Seymour <jon.seymour@gmail.com> wrote:\n>\n> For example:\n>\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\nSverre has pointed out I screwed the example up again. It should have been:\n\ngit bisect start HEAD <some-known-good-commit> <boundary-commits> --no-checkout\ngit 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\nI think the examples in the documentation and test are correct (modulo\nan accurate description of what good choices for <boundary-commit>'s\nare).\n\njon.\n"},{"id":"172461","messageId":"CAP8UFD2uWRS4KznUAQCCF8sShGy6+sGWgNsLj8mmO7Ur1CDrCQ@mail.gmail.com","threadId":"27968","inReplyTo":"1312113321-28760-5-git-send-email-jon.seymour@gmail.com","subject":"Re: [PATCH v8 4/7] bisect: introduce --no-checkout, --update-ref=<ref> support into porcelain.","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2011-07-31T18:35:12Z","receivedAt":"2011-07-31T18:35:12Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Sun, Jul 31, 2011 at 1:55 PM, Jon Seymour <jon.seymour@gmail.com> wrote:\n>\n> @@ -69,13 +71,18 @@ bisect_start() {\n>        orig_args=$(git rev-parse --sq-quote \"$@\")\n>        bad_seen=0\n>        eval=''\n> +       BISECT_UPDATE_REF=\n>        while [ $# -gt 0 ]; do\n>            arg=\"$1\"\n>            case \"$arg\" in\n>            --)\n> -               shift\n> -               break\n> -               ;;\n> +               shift; break ;;\n\nPlease don't change this. We try to avoid having many instructions on\nthe same line like this.\n\n> +           --no-checkout)\n> +               BISECT_UPDATE_REF=HEAD; shift ;;\n\nPerhaps:\n\n                   test -z \"$BISECT_UPDATE_REF\" && BISECT_UPDATE_REF=HEAD\n\nso that \"--update-ref=someref --no-checkout\" works the same as\n\"--no-checkout --update-ref=someref\".\n\n> +           --update-ref=*)\n> +               BISECT_UPDATE_REF=${arg#--update-ref=}; shift ;;\n> +           --*)\n> +               die \"$(eval_gettext \"unrecognised option: '\\$arg'\")\" ;;\n>            *)\n>                rev=$(git rev-parse -q --verify \"$arg^{commit}\") || {\n>                    test $has_double_dash -eq 1 &&\n\nThanks,\nChristian.\n"},{"id":"172462","messageId":"CAP8UFD2vCGnejSj=Nwkb+kGCpwUaggh5j2V6zBu0iWqNZwvS3Q@mail.gmail.com","threadId":"27968","inReplyTo":"1312113321-28760-5-git-send-email-jon.seymour@gmail.com","subject":"Re: [PATCH v8 4/7] bisect: introduce --no-checkout, --update-ref=<ref> support into porcelain.","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2011-07-31T19:21:51Z","receivedAt":"2011-07-31T19:21:51Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Sun, Jul 31, 2011 at 1:55 PM, Jon Seymour <jon.seymour@gmail.com> wrote:\n>\n> +       if test -n \"$BISECT_UPDATE_REF\"; then\n> +           eval=\"$eval echo '$BISECT_UPDATE_REF' > '$GIT_DIR/BISECT_UPDATE_REF';\"\n> +       fi\n\nI don't like this very much. In fact I realize that the eval thing we\nuse is buggy because the result of 'eval \"eval\"' will be the result of\nthe last command in \"eval\", so we won't detect if one of the first\ncommand in \"eval\" failed.\n\nSo perhaps something like:\n\n    eval \"$eval\" &&\n+  ( test -n \"$BISECT_UPDATE_REF\" || echo \"$BISECT_UPDATE_REF\" >\n\"$GIT_DIR/BISECT_UPDATE_REF\" ) &&\n    echo \"git bisect start$orig_args\" >>\"$GIT_DIR/BISECT_LOG\" || exit\n\nThanks,\nChristian.\n"},{"id":"172463","messageId":"CAH3AnrqasW=ZSix0YBgxHg8ca2X+YOvSWknbG2mjsy0NaqV+Mw@mail.gmail.com","threadId":"27968","inReplyTo":"CAP8UFD2vCGnejSj=Nwkb+kGCpwUaggh5j2V6zBu0iWqNZwvS3Q@mail.gmail.com","subject":"Re: [PATCH v8 4/7] bisect: introduce --no-checkout, --update-ref=<ref> support into porcelain.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-31T19:40:35Z","receivedAt":"2011-07-31T19:40:35Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"On Mon, Aug 1, 2011 at 5:21 AM, Christian Couder\n<christian.couder@gmail.com> wrote:\n> On Sun, Jul 31, 2011 at 1:55 PM, Jon Seymour <jon.seymour@gmail.com> wrote:\n>>\n>> +       if test -n \"$BISECT_UPDATE_REF\"; then\n>> +           eval=\"$eval echo '$BISECT_UPDATE_REF' > '$GIT_DIR/BISECT_UPDATE_REF';\"\n>> +       fi\n>\n> I don't like this very much. In fact I realize that the eval thing we\n> use is buggy because the result of 'eval \"eval\"' will be the result of\n> the last command in \"eval\", so we won't detect if one of the first\n> command in \"eval\" failed.\n\nHow about I fix the eval stitching so that it uses && rather than ; to\nconnect each statement with a final true at the end so there is no\ndangling &&?\n\n>\n> So perhaps something like:\n>\n>    eval \"$eval\" &&\n> +  ( test -n \"$BISECT_UPDATE_REF\" || echo \"$BISECT_UPDATE_REF\" >\n> \"$GIT_DIR/BISECT_UPDATE_REF\" ) &&\n>    echo \"git bisect start$orig_args\" >>\"$GIT_DIR/BISECT_LOG\" || exit\n>\n\nProbably this would be better :-)\n\n( test -z \"$BISECT_UPDATE_REF\" || echo \"$BISECT_UPDATE_REF\" >\n \"$GIT_DIR/BISECT_UPDATE_REF\" ) &&\n\njon.\n"},{"id":"172464","messageId":"CAH3Anrp+Jynon0O8mQJnKvCNtp0v6oR9pLetmg0B6GnoP2QWMg@mail.gmail.com","threadId":"27968","inReplyTo":"CAP8UFD2uWRS4KznUAQCCF8sShGy6+sGWgNsLj8mmO7Ur1CDrCQ@mail.gmail.com","subject":"Re: [PATCH v8 4/7] bisect: introduce --no-checkout, --update-ref=<ref> support into porcelain.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-31T19:48:40Z","receivedAt":"2011-07-31T19:48:40Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"On Mon, Aug 1, 2011 at 4:35 AM, Christian Couder\n<christian.couder@gmail.com> wrote:\n> On Sun, Jul 31, 2011 at 1:55 PM, Jon Seymour <jon.seymour@gmail.com> wrote:\n>>\n>> @@ -69,13 +71,18 @@ bisect_start() {\n>>        orig_args=$(git rev-parse --sq-quote \"$@\")\n>>        bad_seen=0\n>>        eval=''\n>> +       BISECT_UPDATE_REF=\n>>        while [ $# -gt 0 ]; do\n>>            arg=\"$1\"\n>>            case \"$arg\" in\n>>            --)\n>> -               shift\n>> -               break\n>> -               ;;\n>> +               shift; break ;;\n>\n> Please don't change this. We try to avoid having many instructions on\n> the same line like this.\n\nSure.\n\nFWIW: there are two places in git-am.sh and git-repack.sh that put shift on\nthe same line as another statement,. Also this:\n\n     case \"$arg\" in --) has_double_dash=1; break ;; esac\n\nHowever, 'fixing' those can be another change, assessed on its own merits.\n\n>\n>> +           --no-checkout)\n>> +               BISECT_UPDATE_REF=HEAD; shift ;;\n>\n> Perhaps:\n>\n>                   test -z \"$BISECT_UPDATE_REF\" && BISECT_UPDATE_REF=HEAD\n>\n> so that \"--update-ref=someref --no-checkout\" works the same as\n> \"--no-checkout --update-ref=someref\".\n>\n\nGot the intent, thanks.\n\n How about BISECT_UPDATE_REF=${BISECT_UPDATE_REF:-HEAD}?\n\njon.\n"},{"id":"172465","messageId":"201107312205.57488.chriscool@tuxfamily.org","threadId":"27968","inReplyTo":"CAH3Anrp+Jynon0O8mQJnKvCNtp0v6oR9pLetmg0B6GnoP2QWMg@mail.gmail.com","subject":"Re: [PATCH v8 4/7] bisect: introduce --no-checkout, --update-ref=<ref> support into porcelain.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2011-07-31T20:05:57Z","receivedAt":"2011-07-31T20:05:57Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Sunday 31 July 2011 21:48:40 you wrote:\n> On Mon, Aug 1, 2011 at 4:35 AM, Christian Couder\n> \n> <christian.couder@gmail.com> wrote:\n> > On Sun, Jul 31, 2011 at 1:55 PM, Jon Seymour <jon.seymour@gmail.com> \nwrote:\n> >> @@ -69,13 +71,18 @@ bisect_start() {\n> >>        orig_args=$(git rev-parse --sq-quote \"$@\")\n> >>        bad_seen=0\n> >>        eval=''\n> >> +       BISECT_UPDATE_REF=\n> >>        while [ $# -gt 0 ]; do\n> >>            arg=\"$1\"\n> >>            case \"$arg\" in\n> >>            --)\n> >> -               shift\n> >> -               break\n> >> -               ;;\n> >> +               shift; break ;;\n> > \n> > Please don't change this. We try to avoid having many instructions on\n> > the same line like this.\n> \n> Sure.\n> \n> FWIW: there are two places in git-am.sh and git-repack.sh that put shift on\n> the same line as another statement,. Also this:\n> \n>      case \"$arg\" in --) has_double_dash=1; break ;; esac\n\nYeah, we are not always consistent.\n\n> However, 'fixing' those can be another change, assessed on its own merits.\n\nYeah, but I don't think it's worth it at least for the line above.\n\n> >> +           --no-checkout)\n> >> +               BISECT_UPDATE_REF=HEAD; shift ;;\n> > \n> > Perhaps:\n> > \n> >                   test -z \"$BISECT_UPDATE_REF\" && BISECT_UPDATE_REF=HEAD\n> > \n> > so that \"--update-ref=someref --no-checkout\" works the same as\n> > \"--no-checkout --update-ref=someref\".\n> \n> Got the intent, thanks.\n> \n>  How about BISECT_UPDATE_REF=${BISECT_UPDATE_REF:-HEAD}?\n\nYeah, nice.\n\nThanks,\nChristian.\n"},{"id":"172466","messageId":"201107312207.58818.chriscool@tuxfamily.org","threadId":"27968","inReplyTo":"CAH3AnrqasW=ZSix0YBgxHg8ca2X+YOvSWknbG2mjsy0NaqV+Mw@mail.gmail.com","subject":"Re: [PATCH v8 4/7] bisect: introduce --no-checkout, --update-ref=<ref> support into porcelain.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2011-07-31T20:07:58Z","receivedAt":"2011-07-31T20:07:58Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Sunday 31 July 2011 21:40:35 Jon Seymour wrote:\n> On Mon, Aug 1, 2011 at 5:21 AM, Christian Couder\n> \n> <christian.couder@gmail.com> wrote:\n> > On Sun, Jul 31, 2011 at 1:55 PM, Jon Seymour <jon.seymour@gmail.com> \nwrote:\n> >> +       if test -n \"$BISECT_UPDATE_REF\"; then\n> >> +           eval=\"$eval echo '$BISECT_UPDATE_REF' >\n> >> '$GIT_DIR/BISECT_UPDATE_REF';\" +       fi\n> > \n> > I don't like this very much. In fact I realize that the eval thing we\n> > use is buggy because the result of 'eval \"eval\"' will be the result of\n> > the last command in \"eval\", so we won't detect if one of the first\n> > command in \"eval\" failed.\n> \n> How about I fix the eval stitching so that it uses && rather than ; to\n> connect each statement with a final true at the end so there is no\n> dangling &&?\n\nYeah, please fix it in a separate bug fix patch.\n \n> > So perhaps something like:\n> > \n> >    eval \"$eval\" &&\n> > +  ( test -n \"$BISECT_UPDATE_REF\" || echo \"$BISECT_UPDATE_REF\" >\n> > \"$GIT_DIR/BISECT_UPDATE_REF\" ) &&\n> >    echo \"git bisect start$orig_args\" >>\"$GIT_DIR/BISECT_LOG\" || exit\n> \n> Probably this would be better :-)\n> \n> ( test -z \"$BISECT_UPDATE_REF\" || echo \"$BISECT_UPDATE_REF\" >\n>  \"$GIT_DIR/BISECT_UPDATE_REF\" ) &&\n\nYeah :-)\n\nThanks,\nChristian.\n\nPS: sorry I replied to you only previously\n"},{"id":"172467","messageId":"201107312251.51714.chriscool@tuxfamily.org","threadId":"27968","inReplyTo":"201107312207.58818.chriscool@tuxfamily.org","subject":"Re: [PATCH v8 4/7] bisect: introduce --no-checkout, --update-ref=<ref> support into porcelain.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2011-07-31T20:51:51Z","receivedAt":"2011-07-31T20:51:51Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"> On Sunday 31 July 2011 21:40:35 Jon Seymour wrote:\n> > \n> > Probably this would be better :-)\n> > \n> > ( test -z \"$BISECT_UPDATE_REF\" || echo \"$BISECT_UPDATE_REF\" >\n> >  \"$GIT_DIR/BISECT_UPDATE_REF\" ) &&\n\nOr:\n\n{ test -z \"$BISECT_UPDATE_REF\" || echo \"$BISECT_UPDATE_REF\" > \n\"$GIT_DIR/BISECT_UPDATE_REF\" ; } &&\n\nThanks,\nChristian.\n"},{"id":"172469","messageId":"CAH3AnrqdOZZ4p2kEFJq17_mK4wkbJE-yJBTg-G06Wdev90oMGw@mail.gmail.com","threadId":"27968","inReplyTo":"201107312207.58818.chriscool@tuxfamily.org","subject":"Re: [PATCH v8 4/7] bisect: introduce --no-checkout, --update-ref=<ref> support into porcelain.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-31T21:11:35Z","receivedAt":"2011-07-31T21:11:35Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"On Mon, Aug 1, 2011 at 6:07 AM, Christian Couder\n<chriscool@tuxfamily.org> wrote:\n> On Sunday 31 July 2011 21:40:35 Jon Seymour wrote:\n>> On Mon, Aug 1, 2011 at 5:21 AM, Christian Couder\n>>\n>> <christian.couder@gmail.com> wrote:\n>> > On Sun, Jul 31, 2011 at 1:55 PM, Jon Seymour <jon.seymour@gmail.com>\n> wrote:\n>> >> +       if test -n \"$BISECT_UPDATE_REF\"; then\n>> >> +           eval=\"$eval echo '$BISECT_UPDATE_REF' >\n>> >> '$GIT_DIR/BISECT_UPDATE_REF';\" +       fi\n>> >\n>> > I don't like this very much. In fact I realize that the eval thing we\n>> > use is buggy because the result of 'eval \"eval\"' will be the result of\n>> > the last command in \"eval\", so we won't detect if one of the first\n>> > command in \"eval\" failed.\n>>\n>> How about I fix the eval stitching so that it uses && rather than ; to\n>> connect each statement with a final true at the end so there is no\n>> dangling &&?\n>\n> Yeah, please fix it in a separate bug fix patch.\n>\n\nNext roll-up will contain this as patch 2:\n\n-               eval=\"$eval bisect_write '$state' '$rev' 'nolog'; \"\n+               eval=\"$eval ${eval:+&&} bisect_write '$state' '$rev' 'nolog' \"\n\nThere is a no-checkout-v10 tag on github with the current iteration\n(https://github.com/jonseymour/git/commits/no-checkout-v10).\nThis also contains the v8a patch.\n\nI'll repost on request or once others have had the chance to give feedback.\n\njon.\n"}]}