{"thread":{"id":"10940","subject":"[PATCH] Bisect reset: do nothing when not bisecting.","startedAt":"2007-11-20T05:39:53Z","lastAt":"2007-11-20T05:39:53Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"60389","messageId":"20071120063953.06a3d47e.chriscool@tuxfamily.org","threadId":"10940","inReplyTo":null,"subject":"[PATCH] Bisect reset: do nothing when not bisecting.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2007-11-20T05:39:53Z","receivedAt":"2007-11-20T05:39:53Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Before this patch, using \"git bisect reset\" when not bisecting\ndid a \"git checkout master\" for no good reason.\n\nThis also happened using \"git bisect replay\" when not bisecting\nbecause \"bisect_replay\" starts by calling \"bisect_reset\".\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n git-bisect.sh               |    4 ++++\n t/t6030-bisect-porcelain.sh |   27 ++++++++++++++++++++++++++-\n 2 files changed, 30 insertions(+), 1 deletions(-)\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 01593eb..7a6521e 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -329,6 +329,10 @@ bisect_visualize() {\n }\n \n bisect_reset() {\n+\ttest -f \"$GIT_DIR/BISECT_NAMES\" || {\n+\t\techo \"We are not bisecting.\"\n+\t\treturn\n+\t}\n \tcase \"$#\" in\n \t0) if [ -s \"$GIT_DIR/head-name\" ]; then\n \t       branch=`cat \"$GIT_DIR/head-name\"`\ndiff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh\nindex f09db62..2ba4b00 100755\n--- a/t/t6030-bisect-porcelain.sh\n+++ b/t/t6030-bisect-porcelain.sh\n@@ -71,6 +71,31 @@ test_expect_success 'bisect start with one bad and good' '\n \tgit bisect next\n '\n \n+test_expect_success 'bisect reset: back in the master branch' '\n+\tgit bisect reset &&\n+\techo \"* master\" > branch.expect &&\n+\tgit branch > branch.output &&\n+\tcmp branch.expect branch.output\n+'\n+\n+test_expect_success 'bisect reset: back in another branch' '\n+\tgit checkout -b other &&\n+\tgit bisect start &&\n+\tgit bisect good $HASH1 &&\n+\tgit bisect bad $HASH3 &&\n+\tgit bisect reset &&\n+\techo \"  master\" > branch.expect &&\n+\techo \"* other\" >> branch.expect &&\n+\tgit branch > branch.output &&\n+\tcmp branch.expect branch.output\n+'\n+\n+test_expect_success 'bisect reset when not bisecting' '\n+\tgit bisect reset &&\n+\tgit branch > branch.output &&\n+\tcmp branch.expect branch.output\n+'\n+\n test_expect_success 'bisect reset removes packed refs' '\n \tgit bisect reset &&\n \tgit bisect start &&\n@@ -179,7 +204,7 @@ test_expect_success 'bisect skip: add line and then a new test' '\n \tgit bisect skip &&\n \tgit bisect good > my_bisect_log.txt &&\n \tgrep \"$HASH5 is first bad commit\" my_bisect_log.txt &&\n-\tgit bisect log > log_to_replay.txt\n+\tgit bisect log > log_to_replay.txt &&\n \tgit bisect reset\n '\n \n-- \n1.5.3.5.1816.g0b82e-dirty\n"}]}