{"thread":{"id":"27993","subject":"[PATCH v11->v13] bisect: patch bisect-no-checkout in pu to","startedAt":"2011-08-02T11:41:43Z","lastAt":"2011-08-02T11:41:43Z","messageCount":1,"participants":["Jon Seymour"],"isPatch":true,"patchVersion":11,"patchTotal":null},"messages":[{"id":"172649","messageId":"1312285303-9125-1-git-send-email-jon.seymour@gmail.com","threadId":"27993","inReplyTo":null,"subject":"[PATCH v11->v13] bisect: patch bisect-no-checkout in pu to","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-08-02T11:41:43Z","receivedAt":"2011-08-02T11:41:43Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"This patch can be applied on top of the version of bisect-no-checkout currently\nin pu to:\n\n* change the internal control file from BISECT_NO_CHECKOUT to BISECT_MODE\n* change bisect--helper option from --no-checkout to --bisect-mode\n* change the reference used to track bisection cursor from HEAD to BISECT_HEAD\n* update documentation and tests to match.\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     |    8 +++++---\n git-bisect.sh                |   41 ++++++++++++++++++++++++-----------------\n t/t6030-bisect-porcelain.sh  |   30 +++++++++++++++---------------\n 5 files changed, 49 insertions(+), 40 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..5cfac13 100644\n--- a/builtin/bisect--helper.c\n+++ b/builtin/bisect--helper.c\n@@ -4,7 +4,7 @@\n #include \"bisect.h\"\n \n static const char * const git_bisect_helper_usage[] = {\n-\t\"git bisect--helper --next-all [--no-checkout]\",\n+\t\"git bisect--helper --next-all [--bisect-mode=checkout|update-ref]\",\n \tNULL\n };\n \n@@ -12,11 +12,12 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n {\n \tint next_all = 0;\n \tint no_checkout = 0;\n+\tchar *bisect_mode=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_BOOLEAN(0, \"no-checkout\", &no_checkout,\n-\t\t\t    \"update HEAD instead of checking out the current commit\"),\n+\t\tOPT_STRING(0, \"bisect-mode\", &bisect_mode, \"mode\",\n+\t\t\t    \"the bisection mode either checkout or update-ref. defaults to checkout.\"),\n \t\tOPT_END()\n \t};\n \n@@ -26,6 +27,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n \tif (!next_all)\n \t\tusage_with_options(git_bisect_helper_usage, options);\n \n+\tno_checkout = bisect_mode && !strcmp(bisect_mode, \"update-ref\");\n \t/* next-all */\n \treturn bisect_next_all(prefix, no_checkout);\n }\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 81d2344..c9aabc0 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -34,7 +34,16 @@ 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_NO_CHECKOUT=$(test -f \"$GIT_DIR/BISECT_NO_CHECKOUT\" && cat \"$GIT_DIR/BISECT_NO_CHECKOUT\")\n+BISECT_MODE=$(test -f \"$GIT_DIR/BISECT_MODE\" && cat \"$GIT_DIR/BISECT_MODE\")\n+\n+bisect_head()\n+{\n+    if test \"$BISECT_MODE\" = \"update-ref\"; 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@@ -71,7 +80,7 @@ bisect_start() {\n \torig_args=$(git rev-parse --sq-quote \"$@\")\n \tbad_seen=0\n \teval=''\n-\tBISECT_NO_CHECKOUT=\n+\tBISECT_MODE=checkout\n \twhile [ $# -gt 0 ]; do\n \t    arg=\"$1\"\n \t    case \"$arg\" in\n@@ -80,7 +89,7 @@ bisect_start() {\n \t\tbreak\n \t\t;;\n \t    --no-checkout)\n-\t\tBISECT_NO_CHECKOUT=$arg;\n+\t\tBISECT_MODE=update-ref;\n \t\tshift ;;\n \t    --*)\n \t\tdie \"$(eval_gettext \"unrecognised option: '\\$arg'\")\" ;;\n@@ -115,10 +124,10 @@ 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\tif test -z \"$BISECT_NO_CHECKOUT\"; then\n-\t\t    git checkout \"$start_head\" --\n+\t\tif test \"$BISECT_MODE\" = \"update-ref\"; then\n+\t\t    git update-ref --no-deref $(bisect_head) \"$start_head\"\n \t\telse\n-\t\t    git update-ref --no-deref HEAD \"$start_head\"\n+\t\t    git checkout \"$start_head\" --\n \t\tfi\n \telse\n \t\t# Get rev from where we start.\n@@ -156,10 +165,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-\t    test -z \"$BISECT_NO_CHECKOUT\" ||\n-\t    echo \"$BISECT_NO_CHECKOUT\" > \"$GIT_DIR/BISECT_NO_CHECKOUT\"\n-\t} &&\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@@ -221,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@@ -306,7 +313,7 @@ bisect_next() {\n \tbisect_next_check good\n \n \t# Perform all bisection computation, display and checkout\n-\tgit bisect--helper --next-all ${BISECT_NO_CHECKOUT}\n+\tgit bisect--helper --next-all ${BISECT_MODE:+--bisect-mode=}${BISECT_MODE}\n \tres=$?\n \n         # Check if we should exit because bisection is finished\n@@ -355,15 +362,15 @@ bisect_reset() {\n \t*)\n \t    usage ;;\n \tesac\n-\tif test -z \"$BISECT_NO_CHECKOUT\"; then\n+\tif test \"$BISECT_MODE\" = \"update-ref\"; then\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\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 HEAD $(git rev-parse --symbolic-full-name \"${branch}\")\n \tfi\n }\n \n@@ -379,7 +386,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_NO_CHECKOUT\" &&\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 \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.359.g2d20bc\n"}]}