{"thread":{"id":"10415","subject":"[PATCH 6/9] Bisect: factorise some logging into \"bisect_write\".","startedAt":"2007-10-22T05:48:54Z","lastAt":"2007-10-22T05:48:54Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":9},"messages":[{"id":"56812","messageId":"20071022074854.b1362e76.chriscool@tuxfamily.org","threadId":"10415","inReplyTo":null,"subject":"[PATCH 6/9] Bisect: factorise some logging into \"bisect_write\".","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2007-10-22T05:48:54Z","receivedAt":"2007-10-22T05:48:54Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Also use \"die\" instead of \"echo >&2 something ; exit 1\".\nAnd simplify \"bisect_replay\".\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n git-bisect.sh |   46 +++++++++++++---------------------------------\n 1 files changed, 13 insertions(+), 33 deletions(-)\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 82aa404..d7f0a20 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -106,12 +106,11 @@ bisect_start() {\n \t\t        die \"'$arg' does not appear to be a valid revision\"\n \t\t    break\n \t\t}\n-\t\tif [ $bad_seen -eq 0 ]; then\n-\t\t    bad_seen=1\n-\t\t    bisect_write 'bad' \"$rev\"\n-\t\telse\n-\t\t    bisect_write 'good' \"$rev\"\n-\t\tfi\n+\t\tcase $bad_seen in\n+\t\t0) state='bad' ; bad_seen=1 ;;\n+\t\t*) state='good' ;;\n+\t\tesac\n+\t\tbisect_write \"$state\" \"$rev\" 'nolog'\n \t\tshift\n \t\t;;\n \t    esac\n@@ -132,6 +131,7 @@ bisect_write() {\n \tesac\n \techo \"$rev\" >\"$GIT_DIR/refs/bisect/$tag\"\n \techo \"# $state: \"$(git show-branch $rev) >>\"$GIT_DIR/BISECT_LOG\"\n+\ttest -z \"$nolog\" && echo \"git-bisect $state $rev\" >>\"$GIT_DIR/BISECT_LOG\"\n }\n \n bisect_bad() {\n@@ -145,7 +145,6 @@ bisect_bad() {\n \t\tusage ;;\n \tesac || exit\n \tbisect_write 'bad' \"$rev\"\n-\techo \"git-bisect bad $rev\" >>\"$GIT_DIR/BISECT_LOG\"\n \tbisect_auto_next\n }\n \n@@ -160,7 +159,6 @@ bisect_good() {\n \tdo\n \t\trev=$(git rev-parse --verify \"$rev^{commit}\") || exit\n \t\tbisect_write 'good' \"$rev\"\n-\t\techo \"git-bisect good $rev\" >>\"$GIT_DIR/BISECT_LOG\"\n \tdone\n \tbisect_auto_next\n }\n@@ -176,7 +174,6 @@ bisect_skip() {\n \tdo\n \t\trev=$(git rev-parse --verify \"$rev^{commit}\") || exit\n \t\tbisect_write 'skip' \"$rev\"\n-\t\techo \"git-bisect skip $rev\" >>\"$GIT_DIR/BISECT_LOG\"\n \tdone\n \tbisect_auto_next\n }\n@@ -352,10 +349,8 @@ bisect_reset() {\n \t   else\n \t       branch=master\n \t   fi ;;\n-\t1) git show-ref --verify --quiet -- \"refs/heads/$1\" || {\n-\t       echo >&2 \"$1 does not seem to be a valid branch\"\n-\t       exit 1\n-\t   }\n+\t1) git show-ref --verify --quiet -- \"refs/heads/$1\" ||\n+\t       die \"$1 does not seem to be a valid branch\"\n \t   branch=\"$1\" ;;\n \t*)\n \t    usage ;;\n@@ -375,10 +370,7 @@ bisect_clean_state() {\n }\n \n bisect_replay () {\n-\ttest -r \"$1\" || {\n-\t\techo >&2 \"cannot read $1 for replaying\"\n-\t\texit 1\n-\t}\n+\ttest -r \"$1\" || die \"cannot read $1 for replaying\"\n \tbisect_reset\n \twhile read bisect command rev\n \tdo\n@@ -386,23 +378,11 @@ bisect_replay () {\n \t\tcase \"$command\" in\n \t\tstart)\n \t\t\tcmd=\"bisect_start $rev\"\n-\t\t\teval \"$cmd\"\n-\t\t\t;;\n-\t\tgood)\n-\t\t\tbisect_write 'good' \"$rev\"\n-\t\t\techo \"git-bisect good $rev\" >>\"$GIT_DIR/BISECT_LOG\"\n-\t\t\t;;\n-\t\tbad)\n-\t\t\tbisect_write 'bad' \"$rev\"\n-\t\t\techo \"git-bisect bad $rev\" >>\"$GIT_DIR/BISECT_LOG\"\n-\t\t\t;;\n-\t\tskip)\n-\t\t\tbisect_write 'skip' \"$rev\"\n-\t\t\techo \"git-bisect skip $rev\" >>\"$GIT_DIR/BISECT_LOG\"\n-\t\t\t;;\n+\t\t\teval \"$cmd\" ;;\n+\t\tgood|bad|skip)\n+\t\t\tbisect_write \"$command\" \"$rev\" ;;\n \t\t*)\n-\t\t\techo >&2 \"?? what are you talking about?\"\n-\t\t\texit 1 ;;\n+\t\t\tdie \"?? what are you talking about?\" ;;\n \t\tesac\n \tdone <\"$1\"\n \tbisect_auto_next\n-- \n1.5.3.3.136.g591d1-dirty\n"}]}