{"thread":{"id":"18561","subject":"[PATCH 10/10] bisect: use \"bisect--helper\" and remove \"filter_skipped\" function","startedAt":"2009-03-26T04:56:02Z","lastAt":"2009-03-26T04:56:02Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":10},"messages":[{"id":"109482","messageId":"20090326055602.b0fc796f.chriscool@tuxfamily.org","threadId":"18561","inReplyTo":null,"subject":"[PATCH 10/10] bisect: use \"bisect--helper\" and remove \"filter_skipped\" function","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2009-03-26T04:56:02Z","receivedAt":"2009-03-26T04:56:02Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Use the new \"git bisect--helper\" builtin. It should be faster and\nsafer instead of the old \"filter_skipped\" shell function. And it\nis a first step to move more shell code to C.\n\nAs the output is a little bit different we have to change the code\nthat interpret the results. But these changes improve code clarity.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n git-bisect.sh |   89 ++++++++-------------------------------------------------\n 1 files changed, 12 insertions(+), 77 deletions(-)\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex e313bde..0f7590d 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -279,76 +279,13 @@ bisect_auto_next() {\n \tbisect_next_check && bisect_next || :\n }\n \n-filter_skipped() {\n+eval_and_string_together() {\n \t_eval=\"$1\"\n-\t_skip=\"$2\"\n-\n-\tif [ -z \"$_skip\" ]; then\n-\t\teval \"$_eval\" | {\n-\t\t\twhile read line\n-\t\t\tdo\n-\t\t\t\techo \"$line &&\"\n-\t\t\tdone\n-\t\t\techo ':'\n-\t\t}\n-\t\treturn\n-\tfi\n \n-\t# Let's parse the output of:\n-\t# \"git rev-list --bisect-vars --bisect-all ...\"\n \teval \"$_eval\" | {\n-\t\tVARS= FOUND= TRIED=\n-\t\twhile read hash line\n+\t\twhile read line\n \t\tdo\n-\t\t\tcase \"$VARS,$FOUND,$TRIED,$hash\" in\n-\t\t\t1,*,*,*)\n-\t\t\t\t# \"bisect_foo=bar\" read from rev-list output.\n-\t\t\t\techo \"$hash &&\"\n-\t\t\t\t;;\n-\t\t\t,*,*,---*)\n-\t\t\t\t# Separator\n-\t\t\t\t;;\n-\t\t\t,,,bisect_rev*)\n-\t\t\t\t# We had nothing to search.\n-\t\t\t\techo \"bisect_rev= &&\"\n-\t\t\t\tVARS=1\n-\t\t\t\t;;\n-\t\t\t,,*,bisect_rev*)\n-\t\t\t\t# We did not find a good bisect rev.\n-\t\t\t\t# This should happen only if the \"bad\"\n-\t\t\t\t# commit is also a \"skip\" commit.\n-\t\t\t\techo \"bisect_rev='$TRIED' &&\"\n-\t\t\t\tVARS=1\n-\t\t\t\t;;\n-\t\t\t,,*,*)\n-\t\t\t\t# We are searching.\n-\t\t\t\tTRIED=\"${TRIED:+$TRIED|}$hash\"\n-\t\t\t\tcase \"$_skip\" in\n-\t\t\t\t*$hash*) ;;\n-\t\t\t\t*)\n-\t\t\t\t\techo \"bisect_rev=$hash &&\"\n-\t\t\t\t\techo \"bisect_tried='$TRIED' &&\"\n-\t\t\t\t\tFOUND=1\n-\t\t\t\t\t;;\n-\t\t\t\tesac\n-\t\t\t\t;;\n-\t\t\t,1,*,bisect_rev*)\n-\t\t\t\t# We have already found a rev to be tested.\n-\t\t\t\tVARS=1\n-\t\t\t\t;;\n-\t\t\t,1,*,*)\n-\t\t\t\t;;\n-\t\t\t*)\n-\t\t\t\t# Unexpected input\n-\t\t\t\techo \"die 'filter_skipped error'\"\n-\t\t\t\tdie \"filter_skipped error \" \\\n-\t\t\t\t    \"VARS: '$VARS' \" \\\n-\t\t\t\t    \"FOUND: '$FOUND' \" \\\n-\t\t\t\t    \"TRIED: '$TRIED' \" \\\n-\t\t\t\t    \"hash: '$hash' \" \\\n-\t\t\t\t    \"line: '$line'\"\n-\t\t\t\t;;\n-\t\t\tesac\n+\t\t\techo \"$line &&\"\n \t\tdone\n \t\techo ':'\n \t}\n@@ -356,10 +293,12 @@ filter_skipped() {\n \n exit_if_skipped_commits () {\n \t_tried=$1\n-\tif expr \"$_tried\" : \".*[|].*\" > /dev/null ; then\n+\t_bad=$2\n+\tif test -n \"$_tried\" ; then\n \t\techo \"There are only 'skip'ped commit left to test.\"\n \t\techo \"The first bad commit could be any of:\"\n \t\techo \"$_tried\" | tr '[|]' '[\\012]'\n+\t\ttest -n \"$_bad\" && echo \"$_bad\"\n \t\techo \"We cannot bisect more!\"\n \t\texit 2\n \tfi\n@@ -490,28 +429,24 @@ 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-\teval=\"$eval $(cat \"$GIT_DIR/BISECT_NAMES\")\" &&\n-\teval=$(filter_skipped \"$eval\" \"$skip\") &&\n+\teval=\"git bisect--helper --next-vars\" &&\n+\teval=$(eval_and_string_together \"$eval\") &&\n \teval \"$eval\" || exit\n \n \tif [ -z \"$bisect_rev\" ]; then\n+\t\t# We should exit here only if the \"bad\"\n+\t\t# commit is also a \"skip\" commit (see above).\n+\t\texit_if_skipped_commits \"$bisect_tried\"\n \t\techo \"$bad was both good and bad\"\n \t\texit 1\n \tfi\n \tif [ \"$bisect_rev\" = \"$bad\" ]; then\n-\t\texit_if_skipped_commits \"$bisect_tried\"\n+\t\texit_if_skipped_commits \"$bisect_tried\" \"$bad\"\n \t\techo \"$bisect_rev is first bad commit\"\n \t\tgit diff-tree --pretty $bisect_rev\n \t\texit 0\n \tfi\n \n-\t# We should exit here only if the \"bad\"\n-\t# commit is also a \"skip\" commit (see above).\n-\texit_if_skipped_commits \"$bisect_rev\"\n-\n \tbisect_checkout \"$bisect_rev\" \"$bisect_nr revisions left to test after this (roughly $bisect_steps steps)\"\n }\n \n-- \n1.6.2.1.317.g3d804\n"}]}