{"thread":{"id":"7924","subject":"[RFC/PATCH] Bisect: add special treatment for bangs passed to \"bisect run\".","startedAt":"2007-05-01T09:31:12Z","lastAt":"2007-05-01T09:44:03Z","messageCount":2,"participants":["Christian Couder","Uwe Kleine-König"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"40808","messageId":"20070501113112.c4b32b55.chriscool@tuxfamily.org","threadId":"7924","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-01T09:31:12Z","receivedAt":"2007-05-01T09:31:12Z","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 adding them back when evaluating \"$@\".\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n git-bisect.sh               |   25 +++++++++++++++++++++++--\n t/t6030-bisect-porcelain.sh |    9 +++++++++\n 2 files changed, 32 insertions(+), 2 deletions(-)\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 1cd4561..f4ce199 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -307,10 +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+      # Run the command/script passed as argument.\n+      if [ $bang_count -eq 0 ]; then\n+\t  echo \"running $@\"\n+\t  \"$@\"\n+      else\n+\t  if [ $bang_modulo -eq 0 ]; then\n+\t      echo \"running ! ( ! $@ )\"\n+\t      ! ( ! \"$@\" )\n+\t  else\n+\t      echo \"running ! $@\"\n+\t      ! \"$@\"\n+\t  fi\n+      fi\n       res=$?\n \n       # Check for really bad run error.\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"},{"id":"40811","messageId":"20070501094403.GA7613@informatik.uni-freiburg.de","threadId":"7924","inReplyTo":"20070501113112.c4b32b55.chriscool@tuxfamily.org","subject":"Re: [RFC/PATCH] Bisect: add special treatment for bangs passed to \"bisect run\".","fromName":"Uwe Kleine-König","fromEmail":"ukleinek@informatik.uni-freiburg.de","sentAt":"2007-05-01T09:44:03Z","receivedAt":"2007-05-01T09:44:03Z","isPatch":true,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Hallo Christian,\n\n> Something like:\n> \n>  $ git bisect run ! grep string my_file\n> \n> does not work right now, probably because '!' is a shell keyword.\n\nI didn't check you patch in deep, but you should consider that the\nspecial meaning of \"!\" isn't implemented in the original Bourne\nShell[1].\n\nIIRC this or something similar was brought up some time ago and the\nresult was, that your script has to do the negation if needed.\n\nBest regards\nUwe\n\n[1] login@~ > uname -a\n    SunOS login 5.10 Generic_118833-36 sun4u sparc\n\n    login@~ > /bin/sh -c \"! true\"\n    /bin/sh: !: not found\n\n-- \nUwe Kleine-König\n\ncal 9 1752 | grep 10\n"}]}