{"thread":{"id":"18995","subject":"[PATCH] bisect: remove Perl use by implementing \"git bisect--helper --sq-quote\"","startedAt":"2009-04-22T04:55:23Z","lastAt":"2009-04-23T19:20:01Z","messageCount":3,"participants":["Christian Couder","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"111919","messageId":"20090422045524.3606.81842.chriscool@tuxfamily.org","threadId":"18995","inReplyTo":null,"subject":"[PATCH] bisect: remove Perl use by implementing \"git bisect--helper --sq-quote\"","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2009-04-22T04:55:23Z","receivedAt":"2009-04-22T04:55:23Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"The sq() function in \"git-bisect.sh\" was the only place where Perl\nwas needed. This patch remove this use of Perl by implementing\na new \"--sq-quote\" option in \"builtin-bisect--helper.c\".\n\nWhile at it we remove the line in the Makefile that replaced @@PERL@@\nby the shell quoted perl path in the shell scripts, because no more\nshell script needs that. (\"git-instaweb.sh\" is dealt with separetely\nin the Makefile.)\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n Makefile                 |    1 -\n builtin-bisect--helper.c |   25 ++++++++++++++++++++++---\n git-bisect.sh            |    8 +-------\n 3 files changed, 23 insertions(+), 11 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex b630408..329b0a4 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1238,7 +1238,6 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh\n \t$(QUIET_GEN)$(RM) $@ $@+ && \\\n \tsed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \\\n \t    -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \\\n-\t    -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \\\n \t    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \\\n \t    -e 's/@@NO_CURL@@/$(NO_CURL)/g' \\\n \t    $@.sh >$@+ && \\\ndiff --git a/builtin-bisect--helper.c b/builtin-bisect--helper.c\nindex aca7018..098ac84 100644\n--- a/builtin-bisect--helper.c\n+++ b/builtin-bisect--helper.c\n@@ -1,27 +1,46 @@\n #include \"builtin.h\"\n #include \"cache.h\"\n #include \"parse-options.h\"\n+#include \"quote.h\"\n #include \"bisect.h\"\n \n static const char * const git_bisect_helper_usage[] = {\n \t\"git bisect--helper --next-exit\",\n+\t\"git bisect--helper --sq-quote ARG1...\",\n \tNULL\n };\n \n+static int print_sq_quote_argv(int argc, const char **argv)\n+{\n+\tstruct strbuf buf = STRBUF_INIT;\n+\n+\tif (argc)\n+\t\tsq_quote_argv(&buf, argv, 0);\n+\tprintf(\"%s\\n\", buf.buf);\n+\tstrbuf_release(&buf);\n+\n+\treturn 0;\n+}\n+\n int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n {\n \tint next_exit = 0;\n+\tint sq_quote = 0;\n \tstruct option options[] = {\n \t\tOPT_BOOLEAN(0, \"next-exit\", &next_exit,\n \t\t\t    \"output bisect result and exit instuctions\"),\n+\t\tOPT_BOOLEAN(0, \"sq-quote\", &sq_quote,\n+\t\t\t    \"output shell quoted arguments\"),\n \t\tOPT_END()\n \t};\n \n \targc = parse_options(argc, argv, options, git_bisect_helper_usage, 0);\n \n-\tif (!next_exit)\n+\tif ((next_exit && sq_quote) || (!next_exit && !sq_quote))\n \t\tusage_with_options(git_bisect_helper_usage, options);\n \n-\t/* next-exit */\n-\treturn bisect_next_exit(prefix);\n+\tif (sq_quote)\n+\t\treturn print_sq_quote_argv(argc, argv);\n+\telse /* next-exit */\n+\t\treturn bisect_next_exit(prefix);\n }\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex e1f300b..93ecfeb 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -34,13 +34,7 @@ _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'\n _x40=\"$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40\"\n \n sq() {\n-\t@@PERL@@ -e '\n-\t\tfor (@ARGV) {\n-\t\t\ts/'\\''/'\\'\\\\\\\\\\'\\''/g;\n-\t\t\tprint \" '\\''$_'\\''\";\n-\t\t}\n-\t\tprint \"\\n\";\n-\t' \"$@\"\n+\tgit bisect--helper --sq-quote \"$@\"\n }\n \n bisect_autostart() {\n-- \n1.6.2.2.537.g3b83b\n"},{"id":"111923","messageId":"7veivl444b.fsf@gitster.siamese.dyndns.org","threadId":"18995","inReplyTo":"20090422045524.3606.81842.chriscool@tuxfamily.org","subject":"Re: [PATCH] bisect: remove Perl use by implementing \"git bisect--helper --sq-quote\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-22T06:03:16Z","receivedAt":"2009-04-22T06:03:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Couder <chriscool@tuxfamily.org> writes:\n\n> The sq() function in \"git-bisect.sh\" was the only place where Perl\n> was needed. This patch remove this use of Perl by implementing\n> a new \"--sq-quote\" option in \"builtin-bisect--helper.c\".\n\nIsn't it because only git-bisect.sh for whatever reason reimplements sq\nusing Perl while original implementation in am used sed for more\nportability?\n\nI would suspect, if it were 3 years ago, that any serious porcelain\nwriters would have very much appreciated such a feature that gives shell\nprogrammers an easy access to a quoting function that allows a safe eval,\nand I would have strongly suggested that the feature to be implemented in\na more permanent place rather than in bisect--helper; perhaps a better\nplace would be the kitchen-sink \"rev-parse\".\n\nBut given that nobody seems competent enough to do serious programming in\nshell these days, I am not sure if the choice between bisect--helper and\nrev-parse makes much of a difference ;-).\n"},{"id":"112118","messageId":"200904232120.01300.chriscool@tuxfamily.org","threadId":"18995","inReplyTo":"7veivl444b.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] bisect: remove Perl use by implementing \"git bisect--helper --sq-quote\"","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2009-04-23T19:20:01Z","receivedAt":"2009-04-23T19:20:01Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Le mercredi 22 avril 2009, Junio C Hamano a écrit :\n> Christian Couder <chriscool@tuxfamily.org> writes:\n> > The sq() function in \"git-bisect.sh\" was the only place where Perl\n> > was needed. This patch remove this use of Perl by implementing\n> > a new \"--sq-quote\" option in \"builtin-bisect--helper.c\".\n>\n> Isn't it because only git-bisect.sh for whatever reason reimplements sq\n> using Perl while original implementation in am used sed for more\n> portability?\n\nWell I saw that there was some work going to remove perl dependencies, so I \nthought that I might help by removing the Perl dependency from \ngit-bisect.sh.\n\nI didn't look at other places where sq is implemented otherwise. I just \nchecked other shell scripts where there is @@PERL@@.\n\n> I would suspect, if it were 3 years ago, that any serious porcelain\n> writers would have very much appreciated such a feature that gives shell\n> programmers an easy access to a quoting function that allows a safe eval,\n> and I would have strongly suggested that the feature to be implemented in\n> a more permanent place rather than in bisect--helper; perhaps a better\n> place would be the kitchen-sink \"rev-parse\".\n\nI did it in bisect--helper because I was working on it, and I wanted to do \nit in C because I am porting bisect stuff to C.\n\nBut now that you pointed that sq is also implemented in git-am.sh, I agree \nthat it would be perhaps better if it was implemented in something \nlike \"rev-parse\". And then it could be used both in \"git-bisect.sh\" and \nin \"git-am.sh\".\n\n> But given that nobody seems competent enough to do serious programming in\n> shell these days, I am not sure if the choice between bisect--helper and\n> rev-parse makes much of a difference ;-).\n\nWe never know, it might become trendy again ;-)\n\nBest regards,\nChristian.\n"}]}