{"thread":{"id":"16267","subject":"[PATCH 9/9 v4] bisect: add \"--no-replace\" option to bisect without using replace branches","startedAt":"2008-11-11T05:46:07Z","lastAt":"2008-11-11T05:46:07Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":4,"patchTotal":9},"messages":[{"id":"95437","messageId":"20081111064607.e5632ed9.chriscool@tuxfamily.org","threadId":"16267","inReplyTo":null,"subject":"[PATCH 9/9 v4] bisect: add \"--no-replace\" option to bisect without using replace branches","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2008-11-11T05:46:07Z","receivedAt":"2008-11-11T05:46:07Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n Documentation/git-bisect.txt |    6 +++++-\n git-bisect.sh                |   26 ++++++++++++++++++++------\n t/t6035-bisect-replace.sh    |   10 ++++++++++\n 3 files changed, 35 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt\nindex 3834a34..ce8d7c1 100644\n--- a/Documentation/git-bisect.txt\n+++ b/Documentation/git-bisect.txt\n@@ -16,7 +16,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-replace] [<bad> [<good>...]] [--] [<paths>...]\n  git bisect bad [<rev>]\n  git bisect good [<rev>...]\n  git bisect skip [<rev>...]\n@@ -247,6 +247,10 @@ As the branches created by \"git bisect replace\" can be shared between\n developers, this feature might be especially usefull on big projects\n where many people often bisect the same code base.\n \n+If you give the `--no-replace` to \"git bisect start\", then the\n+\"bisect-replace-*\" branches will not be used for the bisection you\n+start.\n+\n Bisect run\n ~~~~~~~~~~\n \ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex be37b64..5a65ab5 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|replace|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-replace] [<bad> [<good>...]] [--] [<pathspec>...]\n         reset bisect state and start bisection.\n git bisect bad [<rev>]\n         mark <rev> a known-bad revision.\n@@ -119,6 +119,10 @@ bisect_start() {\n \t\tshift\n \t\tbreak\n \t\t;;\n+\t    --no-replace)\n+\t\tshift\n+\t\ttouch \"$GIT_DIR/BISECT_NO_REPLACE\"\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@@ -386,6 +390,16 @@ We continue anyway.\n EOF\n }\n \n+replace_option() {\n+\ttest -f \"$GIT_DIR/BISECT_NO_REPLACE\" ||\n+\t\techo \"--bisect-replace\"\n+}\n+\n+no_replace_option() {\n+\ttest ! -f \"$GIT_DIR/BISECT_NO_REPLACE\" ||\n+\t\techo \"--no-bisect-replace\"\n+}\n+\n #\n # \"check_merge_bases\" checks that merge bases are not \"bad\".\n #\n@@ -401,7 +415,7 @@ check_merge_bases() {\n \t_bad=\"$1\"\n \t_good=\"$2\"\n \t_skip=\"$3\"\n-\tfor _mb in $(git merge-base --all --bisect-replace $_bad $_good)\n+\tfor _mb in $(git merge-base --all $(replace_option) $_bad $_good)\n \tdo\n \t\tif is_among \"$_mb\" \"$_good\"; then\n \t\t\tcontinue\n@@ -436,7 +450,7 @@ check_good_are_ancestors_of_bad() {\n \t# Bisecting with no good rev is ok\n \ttest -z \"$_good\" && return\n \n-\t_side=$(git rev-list --bisect-replace $_good ^$_bad)\n+\t_side=$(git rev-list $(replace_option) $_good ^$_bad)\n \tif test -n \"$_side\"; then\n \t\t# Return if a checkout was done\n \t\tcheck_merge_bases \"$_bad\" \"$_good\" \"$_skip\" || return\n@@ -465,9 +479,8 @@ bisect_next() {\n \ttest \"$?\" -eq \"1\" && return\n \n \t# Get bisection information\n-\tBISECT_OPT=''\n-\ttest -n \"$skip\" && BISECT_OPT='--bisect-all'\n-\teval=\"git rev-list --bisect-vars $BISECT_OPT $good $bad --\" &&\n+\tBISECT_OPTS=\"$(no_replace_option) --bisect-vars ${skip:+--bisect-all}\"\n+\teval=\"git rev-list $BISECT_OPTS $good $bad --\" &&\n \teval=\"$eval $(cat \"$GIT_DIR/BISECT_NAMES\")\" &&\n \teval=$(filter_skipped \"$eval\" \"$skip\") &&\n \teval \"$eval\" || exit\n@@ -534,6 +547,7 @@ bisect_clean_state() {\n \tdo\n \t\tgit update-ref -d $ref $hash || exit\n \tdone\n+\trm -f \"$GIT_DIR/BISECT_NO_REPLACE\" &&\n \trm -f \"$GIT_DIR/BISECT_EXPECTED_REV\" &&\n \trm -f \"$GIT_DIR/BISECT_ANCESTORS_OK\" &&\n \trm -f \"$GIT_DIR/BISECT_LOG\" &&\ndiff --git a/t/t6035-bisect-replace.sh b/t/t6035-bisect-replace.sh\nindex f22a2e5..b9cc739 100755\n--- a/t/t6035-bisect-replace.sh\n+++ b/t/t6035-bisect-replace.sh\n@@ -164,6 +164,16 @@ test_expect_success '\"git rev-list --no-bisect-replace\" works' '\n      grep $HASH4 rev_list.txt\n '\n \n+test_expect_success 'git bisect works with --no-replace' '\n+     git bisect start --no-replace $HASH5 $HASH1 &&\n+     test \"$(git rev-parse --verify HEAD)\" = \"$HASH3\" &&\n+     git bisect good &&\n+     test \"$(git rev-parse --verify HEAD)\" = \"$HASH4\" &&\n+     git bisect bad > my_bisect_log.txt &&\n+     grep \"$HASH4 is first bad commit\" my_bisect_log.txt &&\n+     git bisect reset\n+'\n+\n #\n #\n test_done\n-- \n1.6.0.3.614.g0f3b9\n"}]}