{"thread":{"id":"13624","subject":"[PATCH 2/3] bisect: fix left over \"BISECT_START\" file when starting with junk rev","startedAt":"2008-05-22T22:38:59Z","lastAt":"2008-05-22T22:38:59Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"77506","messageId":"20080523003859.bf137d31.chriscool@tuxfamily.org","threadId":"13624","inReplyTo":null,"subject":"[PATCH 2/3] bisect: fix left over \"BISECT_START\" file when starting with junk rev","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2008-05-22T22:38:59Z","receivedAt":"2008-05-22T22:38:59Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Before this patch, when using for example:\n\n$ git bisect start <stuff1> <stuff2>\n\nwith <stuff1> or <stuff2> that cannot be parsed as a revision, we\ncould leave a \".git/BISECT_START\" file, from a previous\n\"git bisect start\", alone.\n\nThis patch makes sure that it does not happen by removing the\n\"BISECT_START\" file in \"bisect_clean_state\" and then always writing\nit again at the end of \"bisect_start\".\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n git-bisect.sh               |   16 +++++++---------\n t/t6030-bisect-porcelain.sh |    2 +-\n 2 files changed, 8 insertions(+), 10 deletions(-)\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 164e8ed..0dcb526 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -81,8 +81,8 @@ bisect_start() {\n \tstart_head=''\n \tcase \"$head\" in\n \trefs/heads/bisect)\n-\t\tbranch=`cat \"$GIT_DIR/BISECT_START\"`\n-\t\tgit checkout $branch || exit\n+\t\tstart_head=$(cat \"$GIT_DIR/BISECT_START\")\n+\t\tgit checkout \"$start_head\" || exit\n \t\t;;\n \trefs/heads/*|$_x40)\n \t\t# This error message should only be triggered by cogito usage,\n@@ -134,7 +134,7 @@ bisect_start() {\n \tdone\n \n \tsq \"$@\" >\"$GIT_DIR/BISECT_NAMES\"\n-\ttest -n \"$start_head\" && echo \"$start_head\" >\"$GIT_DIR/BISECT_START\"\n+\techo \"$start_head\" >\"$GIT_DIR/BISECT_START\"\n \teval \"$eval\"\n \techo \"git-bisect start$orig_args\" >>\"$GIT_DIR/BISECT_LOG\"\n \tbisect_auto_next\n@@ -392,12 +392,7 @@ bisect_reset() {\n \t*)\n \t    usage ;;\n \tesac\n-\tif git checkout \"$branch\"; then\n-\t\t# Cleanup head-name if it got left by an old version of git-bisect\n-\t\trm -f \"$GIT_DIR/head-name\"\n-\t\trm -f \"$GIT_DIR/BISECT_START\"\n-\t\tbisect_clean_state\n-\tfi\n+\tgit checkout \"$branch\" && bisect_clean_state\n }\n \n bisect_clean_state() {\n@@ -407,9 +402,12 @@ bisect_clean_state() {\n \tdo\n \t\tgit update-ref -d $ref $hash\n \tdone\n+\trm -f \"$GIT_DIR/BISECT_START\"\n \trm -f \"$GIT_DIR/BISECT_LOG\"\n \trm -f \"$GIT_DIR/BISECT_NAMES\"\n \trm -f \"$GIT_DIR/BISECT_RUN\"\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 \n bisect_replay () {\ndiff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh\nindex 7557fa1..68b5440 100755\n--- a/t/t6030-bisect-porcelain.sh\n+++ b/t/t6030-bisect-porcelain.sh\n@@ -138,7 +138,7 @@ test_expect_success 'bisect start: back in good branch' '\n \tgrep \"* other\" branch.output > /dev/null\n '\n \n-test_expect_failure 'bisect start: no \".git/BISECT_START\" if junk rev' '\n+test_expect_success 'bisect start: no \".git/BISECT_START\" if junk rev' '\n \tgit bisect start $HASH4 $HASH1 -- &&\n \tgit bisect good &&\n \ttest_must_fail git bisect start $HASH4 foo -- &&\n-- \n1.5.5.1.501.g204d8.dirty\n"}]}