summaryrefslogtreecommitdiff
path: root/builtin/for-each-ref.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2013-07-30 08:31:25 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-07-30 15:06:27 (GMT)
commit10d0167fef35c7a4e4e3ef9dd448594b62089c5a (patch)
tree367433861d0aebab3512ce7a82efe5c1d7d9eb36 /builtin/for-each-ref.c
parent8f6a3e5d71fa1800c3f330bab2b6b6399ec7aea7 (diff)
downloadgit-10d0167fef35c7a4e4e3ef9dd448594b62089c5a.zip
git-10d0167fef35c7a4e4e3ef9dd448594b62089c5a.tar.gz
git-10d0167fef35c7a4e4e3ef9dd448594b62089c5a.tar.bz2
for-each-ref, quote: convert *_quote_print -> *_quote_buf
The print_value() function in for-each-ref.c prints values to stdout immediately using {sq|perl|python|tcl}_quote_print(). Change these lower-level quote functions to instead leave their results in strbuf so that we can later add post-processing to the results of them. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/for-each-ref.c')
-rw-r--r--builtin/for-each-ref.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index 7f059c3..1d4083c 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -867,24 +867,29 @@ static void sort_refs(struct ref_sort *sort, struct refinfo **refs, int num_refs
static void print_value(struct refinfo *ref, int atom, int quote_style)
{
struct atom_value *v;
+ struct strbuf sb = STRBUF_INIT;
get_value(ref, atom, &v);
switch (quote_style) {
case QUOTE_NONE:
fputs(v->s, stdout);
break;
case QUOTE_SHELL:
- sq_quote_print(stdout, v->s);
+ sq_quote_buf(&sb, v->s);
break;
case QUOTE_PERL:
- perl_quote_print(stdout, v->s);
+ perl_quote_buf(&sb, v->s);
break;
case QUOTE_PYTHON:
- python_quote_print(stdout, v->s);
+ python_quote_buf(&sb, v->s);
break;
case QUOTE_TCL:
- tcl_quote_print(stdout, v->s);
+ tcl_quote_buf(&sb, v->s);
break;
}
+ if (quote_style != QUOTE_NONE) {
+ fputs(sb.buf, stdout);
+ strbuf_release(&sb);
+ }
}
static int hex1(char ch)