{"thread":{"id":"10877","subject":"[PATCH] Bisect reset: remove bisect refs that may have been packed.","startedAt":"2007-11-15T06:40:13Z","lastAt":"2007-11-15T06:40:13Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"59931","messageId":"20071115074013.8981761d.chriscool@tuxfamily.org","threadId":"10877","inReplyTo":null,"subject":"[PATCH] Bisect reset: remove bisect refs that may have been packed.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2007-11-15T06:40:13Z","receivedAt":"2007-11-15T06:40:13Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"If refs were ever packed in the middle of bisection, the bisect\nrefs were not removed from the \"packed-refs\" file.\n\nThis patch fixes this problem by using \"git update-ref -d $ref $hash\"\nin \"bisect_clean_state\".\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n git-bisect.sh               |   11 ++++++++++-\n t/t6030-bisect-porcelain.sh |   12 ++++++++++++\n 2 files changed, 22 insertions(+), 1 deletions(-)\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 3aac816..73a4da2 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -352,7 +352,16 @@ bisect_reset() {\n \n bisect_clean_state() {\n \trm -fr \"$GIT_DIR/refs/bisect\"\n-\trm -f \"$GIT_DIR/refs/heads/bisect\"\n+\n+\t# There may be some refs packed during bisection.\n+\tgit for-each-ref --format='%(refname) %(objectname)' \\\n+\t\t\"refs/bisect/*\" | while read ref hash\n+\tdo\n+\t\tgit update-ref -d $ref $hash\n+\tdone\n+\n+\thash=$(git show-ref --hash refs/heads/bisect)\n+\tgit update-ref -d refs/heads/bisect $hash\n \trm -f \"$GIT_DIR/BISECT_LOG\"\n \trm -f \"$GIT_DIR/BISECT_NAMES\"\n \trm -f \"$GIT_DIR/BISECT_RUN\"\ndiff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh\nindex 53956c0..f09db62 100755\n--- a/t/t6030-bisect-porcelain.sh\n+++ b/t/t6030-bisect-porcelain.sh\n@@ -71,6 +71,18 @@ test_expect_success 'bisect start with one bad and good' '\n \tgit bisect next\n '\n \n+test_expect_success 'bisect reset removes packed refs' '\n+\tgit bisect reset &&\n+\tgit bisect start &&\n+\tgit bisect good $HASH1 &&\n+\tgit bisect bad $HASH3 &&\n+\tgit pack-refs --all --prune &&\n+\tgit bisect next &&\n+\tgit bisect reset &&\n+\ttest -z \"$(git for-each-ref \"refs/bisect/*\")\" &&\n+\ttest -z \"$(git for-each-ref \"refs/heads/bisect\")\"\n+'\n+\n # $HASH1 is good, $HASH4 is bad, we skip $HASH3\n # but $HASH2 is bad,\n # so we should find $HASH2 as the first bad commit\n-- \n1.5.3.5.1728.g34b3e-dirty\n"}]}