* [PATCH] bisect: remove Perl use by implementing "git bisect--helper --sq-quote"
@ 2009-04-22 4:55 Christian Couder
2009-04-22 6:03 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Christian Couder @ 2009-04-22 4:55 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] bisect: remove Perl use by implementing "git bisect--helper --sq-quote"
2009-04-22 4:55 [PATCH] bisect: remove Perl use by implementing "git bisect--helper --sq-quote" Christian Couder
@ 2009-04-22 6:03 ` Junio C Hamano
2009-04-23 19:20 ` Christian Couder
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2009-04-22 6:03 UTC (permalink / raw)
To: Christian Couder; +Cc: git
Christian Couder <chriscool@tuxfamily.org> writes:
> 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".
Isn't it because only git-bisect.sh for whatever reason reimplements sq
using Perl while original implementation in am used sed for more
portability?
I would suspect, if it were 3 years ago, that any serious porcelain
writers would have very much appreciated such a feature that gives shell
programmers an easy access to a quoting function that allows a safe eval,
and I would have strongly suggested that the feature to be implemented in
a more permanent place rather than in bisect--helper; perhaps a better
place would be the kitchen-sink "rev-parse".
But given that nobody seems competent enough to do serious programming in
shell these days, I am not sure if the choice between bisect--helper and
rev-parse makes much of a difference ;-).
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bisect: remove Perl use by implementing "git bisect--helper --sq-quote"
2009-04-22 6:03 ` Junio C Hamano
@ 2009-04-23 19:20 ` Christian Couder
0 siblings, 0 replies; 3+ messages in thread
From: Christian Couder @ 2009-04-23 19:20 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Le mercredi 22 avril 2009, Junio C Hamano a écrit :
> Christian Couder <chriscool@tuxfamily.org> writes:
> > 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".
>
> Isn't it because only git-bisect.sh for whatever reason reimplements sq
> using Perl while original implementation in am used sed for more
> portability?
Well I saw that there was some work going to remove perl dependencies, so I
thought that I might help by removing the Perl dependency from
git-bisect.sh.
I didn't look at other places where sq is implemented otherwise. I just
checked other shell scripts where there is @@PERL@@.
> I would suspect, if it were 3 years ago, that any serious porcelain
> writers would have very much appreciated such a feature that gives shell
> programmers an easy access to a quoting function that allows a safe eval,
> and I would have strongly suggested that the feature to be implemented in
> a more permanent place rather than in bisect--helper; perhaps a better
> place would be the kitchen-sink "rev-parse".
I did it in bisect--helper because I was working on it, and I wanted to do
it in C because I am porting bisect stuff to C.
But now that you pointed that sq is also implemented in git-am.sh, I agree
that it would be perhaps better if it was implemented in something
like "rev-parse". And then it could be used both in "git-bisect.sh" and
in "git-am.sh".
> But given that nobody seems competent enough to do serious programming in
> shell these days, I am not sure if the choice between bisect--helper and
> rev-parse makes much of a difference ;-).
We never know, it might become trendy again ;-)
Best regards,
Christian.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-04-23 19:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-22 4:55 [PATCH] bisect: remove Perl use by implementing "git bisect--helper --sq-quote" Christian Couder
2009-04-22 6:03 ` Junio C Hamano
2009-04-23 19:20 ` Christian Couder
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).