{"thread":{"id":"7928","subject":"[RFC/PATCH] Bisect: add special treatment for bangs passed to \"bisect run\".","startedAt":"2007-05-01T12:17:25Z","lastAt":"2007-05-01T12:17:25Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"40819","messageId":"20070501141725.8ed0f26a.chriscool@tuxfamily.org","threadId":"7928","inReplyTo":null,"subject":"[RFC/PATCH] Bisect: add special treatment for bangs passed to \"bisect run\".","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2007-05-01T12:17:25Z","receivedAt":"2007-05-01T12:17:25Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Something like:\n\n $ git bisect run ! grep string my_file\n\ndoes not work right now probably because '!' is a shell keyword.\n\n(This simple script shows the problem:\n\n $ echo \"#\"\\!\"/bin/sh\" > ./simple_test.sh\n $ echo \"echo \\\"running:\\\" \\\"\\$@\\\"\" >> ./simple_test.sh\n $ echo \"\\\"\\$@\\\"\" >> ./simple_test.sh\n $ chmod +x ./simple_test.sh\n $ ./simple_test.sh ! grep foo bar.txt\n running: ! grep foo bar.txt\n ./simple_test.sh: line 3: !: command not found\n)\n\nThis patch tries to work around this problem by counting how\nmany bangs are passed at the beginning of the \"bisect run\"\nargument list and changing the exit code accordingly.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n\nHallo Uwe,\n\nLe mardi 1 mai 2007 11:44, Uwe Kleine-König a écrit :\n> Hallo Christian,\n>\n> I didn't check you patch in deep, but you should consider that the\n> special meaning of \"!\" isn't implemented in the original Bourne\n> Shell[1].\n\nYou are right.\n\n> IIRC this or something similar was brought up some time ago and the\n> result was, that your script has to do the negation if needed.\n\nYou mean something like this ?\n\nThanks,\nChristian.\n\n git-bisect.sh               |   19 +++++++++++++++++++\n t/t6030-bisect-porcelain.sh |    9 +++++++++\n 2 files changed, 28 insertions(+), 0 deletions(-)\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 1cd4561..0c40fc9 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -307,12 +307,31 @@ bisect_replay () {\n bisect_run () {\n     bisect_next_check fail\n \n+    # Count '!' because they need special code.\n+    bang_count=0\n+    while [ \"$1\" == '!' ]\n+    do\n+      bang_count=$(expr $bang_count + 1)\n+      shift\n+    done\n+    test $bang_count -gt 0 && bang_modulo=$(expr $bang_count % 2)\n+\n+    # Bisect loop.\n     while true\n     do\n       echo \"running $@\"\n       \"$@\"\n       res=$?\n \n+      # Change res depending on bang count.\n+      if [ $bang_count -gt 0 ]; then\n+\t  if [ $bang_modulo -eq 0 ]; then\n+\t      test $res -gt 0 && res=1\n+\t  else\n+\t      test $res -eq 0 && res=1 || res=0\n+\t  fi\n+      fi\n+\n       # Check for really bad run error.\n       if [ $res -lt 0 -o $res -ge 128 ]; then\n \t  echo >&2 \"bisect run failed:\"\ndiff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh\nindex 30f6ade..56fd645 100755\n--- a/t/t6030-bisect-porcelain.sh\n+++ b/t/t6030-bisect-porcelain.sh\n@@ -99,6 +99,15 @@ test_expect_success \\\n      grep \"$HASH4 is first bad commit\" my_bisect_log.txt &&\n      git bisect reset'\n \n+# We again want to automatically find the commit that\n+# introduced \"Ciao\" into hello.\n+test_expect_success \\\n+    '\"git bisect run\" with bang in argument' \\\n+    'git bisect start $HASH4 $HASH1 &&\n+     git bisect run ! grep Ciao hello > my_bisect_log.txt &&\n+     grep \"$HASH4 is first bad commit\" my_bisect_log.txt &&\n+     git bisect reset'\n+\n #\n #\n test_done\n-- \n1.5.2.rc0.71.g4342-dirty\n"}]}