From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: [PATCH] rev-parse --sq bugfixes.
Date: Sun, 17 Jul 2005 01:06:15 -0700 [thread overview]
Message-ID: <7vslyd3lhk.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <7vmzol29zm.fsf@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Sat, 16 Jul 2005 23:59:57 -0700")
We expect --sq output to be used to construct a string to be
"eval"ed in shell scripts, so we should not be separating the
parameter with LF, which would cause the current command to be
ended.
Also there was a silly thinko for doing the shell quoting.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
*** This is a fix on top of the "git-rev-parse vs IFS" RFC
*** patch.
rev-parse.c | 29 ++++++++++++++++-------------
1 files changed, 16 insertions(+), 13 deletions(-)
bf5a2b2f3cd5693560ab72974f9956c76a8fd667
diff --git a/rev-parse.c b/rev-parse.c
--- a/rev-parse.c
+++ b/rev-parse.c
@@ -50,18 +50,6 @@ static int is_rev_argument(const char *a
}
}
-static void show_rev(int type, const unsigned char *sha1)
-{
- if (no_revs)
- return;
- output_revs++;
-
- /* Hexadecimal string plus possibly a carret;
- * this does not have to be quoted even under output_sq.
- */
- printf("%s%s\n", type == show_type ? "" : "^", sha1_to_hex(sha1));
-}
-
static void show(const char *arg)
{
if (output_sq) {
@@ -75,16 +63,31 @@ static void show(const char *arg)
fputs(arg, stdout);
break;
}
+ while (arg < next)
+ putchar(*arg++);
fputs("'\\''", stdout);
arg = next + 1;
}
putchar(sq);
- putchar('\n');
+ putchar(' ');
}
else
puts(arg);
}
+static void show_rev(int type, const unsigned char *sha1)
+{
+ if (no_revs)
+ return;
+ output_revs++;
+
+ /* Hexadecimal string plus possibly a carret;
+ * this does not have to be quoted even under output_sq.
+ */
+ printf("%s%s%c", type == show_type ? "" : "^", sha1_to_hex(sha1),
+ output_sq ? ' ' : '\n');
+}
+
static void show_rev_arg(char *rev)
{
if (no_revs)
next prev parent reply other threads:[~2005-07-17 8:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-17 6:59 [RFC/PATCH] git-rev-parse vs IFS Junio C Hamano
2005-07-17 8:06 ` Junio C Hamano [this message]
2005-07-18 17:27 ` [PATCH] Help scripts that use git-rev-parse to grok args with SP/TAB/LF Junio C Hamano
2005-07-17 8:45 ` [PATCH] Audit rev-parse users Junio C Hamano
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=7vslyd3lhk.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=torvalds@osdl.org \
/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