{"thread":{"id":"10468","subject":"[PATCH] Bisect run: \"skip\" current commit if script exit code is 125.","startedAt":"2007-10-26T03:39:37Z","lastAt":"2007-10-27T06:12:09Z","messageCount":5,"participants":["Christian Couder","Benoit SIGOURE","Tom Prince","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"57254","messageId":"20071026053937.2831a89b.chriscool@tuxfamily.org","threadId":"10468","inReplyTo":null,"subject":"[PATCH] Bisect run: \"skip\" current commit if script exit code is 125.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2007-10-26T03:39:37Z","receivedAt":"2007-10-26T03:39:37Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"This is incompatible with previous versions because an exit code\nof 125 used to mark current commit as \"bad\". But hopefully this exit\ncode is not much used by test scripts or other programs. (126 and 127\nare used by bash.)\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n Documentation/git-bisect.txt |    8 ++++++--\n git-bisect.sh                |   11 ++++++++++-\n t/t6030-bisect-porcelain.sh  |   40 ++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 56 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt\nindex 785f381..14b7a95 100644\n--- a/Documentation/git-bisect.txt\n+++ b/Documentation/git-bisect.txt\n@@ -183,13 +183,17 @@ $ git bisect run my_script\n \n Note that the \"run\" script (`my_script` in the above example) should\n exit with code 0 in case the current source code is good and with a\n-code between 1 and 127 (included) in case the current source code is\n-bad.\n+code between 1 and 127 (included), except 125 that is special, in case\n+the current source code is bad.\n \n Any other exit code will abort the automatic bisect process. (A\n program that does \"exit(-1)\" leaves $? = 255, see exit(3) manual page,\n the value is chopped with \"& 0377\".)\n \n+The special exit code 125 should be used when the current source code\n+cannot be tested. If the \"run\" script exits with this code, the current\n+revision will be \"skip\"ped, see `git bisect skip` above.\n+\n You may often find that during bisect you want to have near-constant\n tweaks (e.g., s/#define DEBUG 0/#define DEBUG 1/ in a header file, or\n \"revision that does not have this commit needs this patch applied to\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex f8d0099..180c6c2 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -392,7 +392,10 @@ bisect_run () {\n       fi\n \n       # Find current state depending on run success or failure.\n-      if [ $res -gt 0 ]; then\n+      # A special exit code of 125 means cannot test.\n+      if [ $res -eq 125 ]; then\n+\t  state='skip'\n+      elif [ $res -gt 0 ]; then\n \t  state='bad'\n       else\n \t  state='good'\n@@ -404,6 +407,12 @@ bisect_run () {\n \n       cat \"$GIT_DIR/BISECT_RUN\"\n \n+      if grep \"first bad commit could be any of\" \"$GIT_DIR/BISECT_RUN\" \\\n+\t\t> /dev/null; then\n+\t  echo >&2 \"bisect run cannot continue any more\"\n+\t  exit $res\n+      fi\n+\n       if [ $res -ne 0 ]; then\n \t  echo >&2 \"bisect run failed:\"\n \t  echo >&2 \"'bisect_state $state' exited with error code $res\"\ndiff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh\nindex 16d0c4a..53956c0 100755\n--- a/t/t6030-bisect-porcelain.sh\n+++ b/t/t6030-bisect-porcelain.sh\n@@ -177,6 +177,46 @@ test_expect_success 'bisect skip and bisect replay' '\n \tgit bisect reset\n '\n \n+HASH6=\n+test_expect_success 'bisect run & skip: cannot tell between 2' '\n+\tadd_line_into_file \"6: Yet a line.\" hello &&\n+\tHASH6=$(git rev-parse --verify HEAD) &&\n+\techo \"#\"\\!\"/bin/sh\" > test_script.sh &&\n+\techo \"tail -1 hello | grep Ciao > /dev/null && exit 125\" >> test_script.sh &&\n+\techo \"grep line hello > /dev/null\" >> test_script.sh &&\n+\techo \"test \\$? -ne 0\" >> test_script.sh &&\n+\tchmod +x test_script.sh &&\n+\tgit bisect start $HASH6 $HASH1 &&\n+\tif git bisect run ./test_script.sh > my_bisect_log.txt\n+\tthen\n+\t\techo Oops, should have failed.\n+\t\tfalse\n+\telse\n+\t\ttest $? -eq 2 &&\n+\t\tgrep \"first bad commit could be any of\" my_bisect_log.txt &&\n+\t\t! grep $HASH3 my_bisect_log.txt &&\n+\t\t! grep $HASH6 my_bisect_log.txt &&\n+\t\tgrep $HASH4 my_bisect_log.txt &&\n+\t\tgrep $HASH5 my_bisect_log.txt\n+\tfi\n+'\n+\n+HASH7=\n+test_expect_success 'bisect run & skip: find first bad' '\n+\tgit bisect reset &&\n+\tadd_line_into_file \"7: Should be the last line.\" hello &&\n+\tHASH7=$(git rev-parse --verify HEAD) &&\n+\techo \"#\"\\!\"/bin/sh\" > test_script.sh &&\n+\techo \"tail -1 hello | grep Ciao > /dev/null && exit 125\" >> test_script.sh &&\n+\techo \"tail -1 hello | grep day > /dev/null && exit 125\" >> test_script.sh &&\n+\techo \"grep Yet hello > /dev/null\" >> test_script.sh &&\n+\techo \"test \\$? -ne 0\" >> test_script.sh &&\n+\tchmod +x test_script.sh &&\n+\tgit bisect start $HASH7 $HASH1 &&\n+\tgit bisect run ./test_script.sh > my_bisect_log.txt &&\n+\tgrep \"$HASH6 is first bad commit\" my_bisect_log.txt\n+'\n+\n #\n #\n test_done\n-- \n1.5.3.4.1494.g253d\n"},{"id":"57258","messageId":"A43880E9-E496-48AA-BC1C-2C98DFD12370@lrde.epita.fr","threadId":"10468","inReplyTo":"20071026053937.2831a89b.chriscool@tuxfamily.org","subject":"Re: [PATCH] Bisect run: \"skip\" current commit if script exit code is 125.","fromName":"Benoit SIGOURE","fromEmail":"tsuna@lrde.epita.fr","sentAt":"2007-10-26T06:25:21Z","receivedAt":"2007-10-26T06:25:21Z","isPatch":true,"sender":{"key":"tsunanet@gmail.com","avatar":"https://avatars.githubusercontent.com/u/128281?v=4"},"body":"On Oct 26, 2007, at 5:39 AM, Christian Couder wrote:\n\n> This is incompatible with previous versions because an exit code\n> of 125 used to mark current commit as \"bad\". But hopefully this exit\n> code is not much used by test scripts or other programs. (126 and 127\n> are used by bash.)\n>\n> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n> ---\n>  Documentation/git-bisect.txt |    8 ++++++--\n>  git-bisect.sh                |   11 ++++++++++-\n>  t/t6030-bisect-porcelain.sh  |   40 +++++++++++++++++++++++++++++++ \n> +++++++++\n>  3 files changed, 56 insertions(+), 3 deletions(-)\n>\n> diff --git a/Documentation/git-bisect.txt b/Documentation/git- \n> bisect.txt\n> index 785f381..14b7a95 100644\n> --- a/Documentation/git-bisect.txt\n> +++ b/Documentation/git-bisect.txt\n> @@ -183,13 +183,17 @@ $ git bisect run my_script\n>\n>  Note that the \"run\" script (`my_script` in the above example) should\n>  exit with code 0 in case the current source code is good and with a\n> -code between 1 and 127 (included) in case the current source code is\n> -bad.\n> +code between 1 and 127 (included), except 125 that is special, in  \n> case\n> +the current source code is bad.\n>\n>  Any other exit code will abort the automatic bisect process. (A\n>  program that does \"exit(-1)\" leaves $? = 255, see exit(3) manual  \n> page,\n>  the value is chopped with \"& 0377\".)\n>\n> +The special exit code 125 should be used when the current source code\n> +cannot be tested. If the \"run\" script exits with this code, the  \n> current\n> +revision will be \"skip\"ped, see `git bisect skip` above.\n> +\n>  You may often find that during bisect you want to have near-constant\n>  tweaks (e.g., s/#define DEBUG 0/#define DEBUG 1/ in a header file, or\n>  \"revision that does not have this commit needs this patch applied to\n\nSince exit 77 is already used by automake to mean \"skip\", wouldn't it  \nbe better to do the same thing here?\n\nCheers,\n\n-- \nBenoit Sigoure aka Tsuna\nEPITA Research and Development Laboratory\n\n\n"},{"id":"57324","messageId":"200710270702.31923.chriscool@tuxfamily.org","threadId":"10468","inReplyTo":"A43880E9-E496-48AA-BC1C-2C98DFD12370@lrde.epita.fr","subject":"Re: [PATCH] Bisect run: \"skip\" current commit if script exit code is 125.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2007-10-27T05:02:31Z","receivedAt":"2007-10-27T05:02:31Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Le vendredi 26 octobre 2007, Benoit SIGOURE a écrit :\n> On Oct 26, 2007, at 5:39 AM, Christian Couder wrote:\n> >\n> > +The special exit code 125 should be used when the current source code\n> > +cannot be tested. If the \"run\" script exits with this code, the\n> > current\n> > +revision will be \"skip\"ped, see `git bisect skip` above.\n> > [...]\n>\n> Since exit 77 is already used by automake to mean \"skip\", wouldn't it\n> be better to do the same thing here?\n\nI don't think 77 is better, first because for automake this is to ignore \nsome non portable test results \"in environments where they don't make \nsense\", so if we \"bisect run\" the same test script and it returns 77 once, \nit will probably returns 77 everytime because the environment will not have \nchanged after a new revision has been checked out.\n\nAlso there is:\n\n$ grep 77 /usr/include/sysexits.h\n#define EX_NOPERM       77      /* permission denied */\n\nand a search for \"include <sysexits.h>\" in http://www.google.com/codesearch \nreturns a lot of results.\n\nChristian.\n"},{"id":"57325","messageId":"20071027053305.GB3115@hermes.priv","threadId":"10468","inReplyTo":"20071027052834.GA3115@hermes.priv","subject":"Re: [PATCH] Bisect run: \"skip\" current commit if script exit code is 125.","fromName":"Tom Prince","fromEmail":"tom.prince@ualberta.net","sentAt":"2007-10-27T05:33:06Z","receivedAt":"2007-10-27T05:33:06Z","isPatch":true,"sender":{"key":"tom.prince@ualberta.net","avatar":"https://gravatar.com/avatar/a0ad19caee7618876339485106ec994f5202505eecd210ba5c0bd869feaa555a?d=mp&s=160"},"body":"On Sat, Oct 27, 2007 at 07:02:31AM +0200, Christian Couder wrote:\n> Le vendredi 26 octobre 2007, Benoit SIGOURE a écrit :\n> > On Oct 26, 2007, at 5:39 AM, Christian Couder wrote:\n> > >\n> > > +The special exit code 125 should be used when the current source code\n> > > +cannot be tested. If the \"run\" script exits with this code, the\n> > > current\n> > > +revision will be \"skip\"ped, see `git bisect skip` above.\n> > > [...]\n> >\n> Also there is:\n> \n> $ grep 77 /usr/include/sysexits.h\n> #define EX_NOPERM       77      /* permission denied */\n\nHow about \n\n#define EX_TEMPFAIL     75      /* temp failure; user is invited to retry */\n"},{"id":"57327","messageId":"7vabq5ulvq.fsf@gitster.siamese.dyndns.org","threadId":"10468","inReplyTo":"20071027053305.GB3115@hermes.priv","subject":"Re: [PATCH] Bisect run: \"skip\" current commit if script exit code is 125.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-10-27T06:12:09Z","receivedAt":"2007-10-27T06:12:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tom Prince <tom.prince@ualberta.net> writes:\n\n> On Sat, Oct 27, 2007 at 07:02:31AM +0200, Christian Couder wrote:\n>> Le vendredi 26 octobre 2007, Benoit SIGOURE a écrit :\n>> > On Oct 26, 2007, at 5:39 AM, Christian Couder wrote:\n>> > >\n>> > > +The special exit code 125 should be used when the current source code\n>> > > +cannot be tested. If the \"run\" script exits with this code, the\n>> > > current\n>> > > +revision will be \"skip\"ped, see `git bisect skip` above.\n>> > > [...]\n>> >\n>> Also there is:\n>> \n>> $ grep 77 /usr/include/sysexits.h\n>> #define EX_NOPERM       77      /* permission denied */\n>\n> How about \n>\n> #define EX_TEMPFAIL     75      /* temp failure; user is invited to retry */\n\nLet's stop bikeshedding.  125 is as good as anything else.\n"}]}