git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Couder <chriscool@tuxfamily.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH] bisect: remove Perl use by implementing "git bisect--helper --sq-quote"
Date: Wed, 22 Apr 2009 06:55:23 +0200	[thread overview]
Message-ID: <20090422045524.3606.81842.chriscool@tuxfamily.org> (raw)

The sq() function in "git-bisect.sh" was the only place where Perl
was needed. This patch remove this use of Perl by implementing
a new "--sq-quote" option in "builtin-bisect--helper.c".

While at it we remove the line in the Makefile that replaced @@PERL@@
by the shell quoted perl path in the shell scripts, because no more
shell script needs that. ("git-instaweb.sh" is dealt with separetely
in the Makefile.)

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 Makefile                 |    1 -
 builtin-bisect--helper.c |   25 ++++++++++++++++++++++---
 git-bisect.sh            |    8 +-------
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/Makefile b/Makefile
index b630408..329b0a4 100644
--- a/Makefile
+++ b/Makefile
@@ -1238,7 +1238,6 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
 	$(QUIET_GEN)$(RM) $@ $@+ && \
 	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
 	    -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
-	    -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
 	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 	    -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
 	    $@.sh >$@+ && \
diff --git a/builtin-bisect--helper.c b/builtin-bisect--helper.c
index aca7018..098ac84 100644
--- a/builtin-bisect--helper.c
+++ b/builtin-bisect--helper.c
@@ -1,27 +1,46 @@
 #include "builtin.h"
 #include "cache.h"
 #include "parse-options.h"
+#include "quote.h"
 #include "bisect.h"
 
 static const char * const git_bisect_helper_usage[] = {
 	"git bisect--helper --next-exit",
+	"git bisect--helper --sq-quote ARG1...",
 	NULL
 };
 
+static int print_sq_quote_argv(int argc, const char **argv)
+{
+	struct strbuf buf = STRBUF_INIT;
+
+	if (argc)
+		sq_quote_argv(&buf, argv, 0);
+	printf("%s\n", buf.buf);
+	strbuf_release(&buf);
+
+	return 0;
+}
+
 int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
 {
 	int next_exit = 0;
+	int sq_quote = 0;
 	struct option options[] = {
 		OPT_BOOLEAN(0, "next-exit", &next_exit,
 			    "output bisect result and exit instuctions"),
+		OPT_BOOLEAN(0, "sq-quote", &sq_quote,
+			    "output shell quoted arguments"),
 		OPT_END()
 	};
 
 	argc = parse_options(argc, argv, options, git_bisect_helper_usage, 0);
 
-	if (!next_exit)
+	if ((next_exit && sq_quote) || (!next_exit && !sq_quote))
 		usage_with_options(git_bisect_helper_usage, options);
 
-	/* next-exit */
-	return bisect_next_exit(prefix);
+	if (sq_quote)
+		return print_sq_quote_argv(argc, argv);
+	else /* next-exit */
+		return bisect_next_exit(prefix);
 }
diff --git a/git-bisect.sh b/git-bisect.sh
index e1f300b..93ecfeb 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -34,13 +34,7 @@ _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
 _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
 
 sq() {
-	@@PERL@@ -e '
-		for (@ARGV) {
-			s/'\''/'\'\\\\\'\''/g;
-			print " '\''$_'\''";
-		}
-		print "\n";
-	' "$@"
+	git bisect--helper --sq-quote "$@"
 }
 
 bisect_autostart() {
-- 
1.6.2.2.537.g3b83b

             reply	other threads:[~2009-04-22  4:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-22  4:55 Christian Couder [this message]
2009-04-22  6:03 ` [PATCH] bisect: remove Perl use by implementing "git bisect--helper --sq-quote" Junio C Hamano
2009-04-23 19:20   ` Christian Couder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090422045524.3606.81842.chriscool@tuxfamily.org \
    --to=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).