diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-09-04 12:28:12 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-09-04 12:28:12 -0700 |
commit | 4aa04a8f8d8cac0e0fb61251fbc71f292d4ab801 (patch) | |
tree | 8238bf110e06f97ded1b60151bf600f4b8b0d37e /builtin | |
parent | d9fc248987fa160bdc8d114e0f296fa8639331e7 (diff) | |
parent | 82aae5c1e550ef2244221c9badd69771115053a5 (diff) | |
download | git-4aa04a8f8d8cac0e0fb61251fbc71f292d4ab801.tar.gz |
Merge branch 'nd/sq-quote-buf'
Code simplification as a preparatory step to something larger.
* nd/sq-quote-buf:
quote: remove sq_quote_print()
tar-tree: remove dependency on sq_quote_print()
for-each-ref, quote: convert *_quote_print -> *_quote_buf
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/for-each-ref.c | 13 | ||||
-rw-r--r-- | builtin/tar-tree.c | 11 |
2 files changed, 14 insertions, 10 deletions
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index 7f059c31df..1d4083c2dd 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) diff --git a/builtin/tar-tree.c b/builtin/tar-tree.c index 3f1e7012db..ba3ffe69a9 100644 --- a/builtin/tar-tree.c +++ b/builtin/tar-tree.c @@ -26,8 +26,8 @@ int cmd_tar_tree(int argc, const char **argv, const char *prefix) * $0 tree-ish basedir ==> * git archive --format-tar --prefix=basedir tree-ish */ - int i; const char **nargv = xcalloc(sizeof(*nargv), argc + 3); + struct strbuf sb = STRBUF_INIT; char *basedir_arg; int nargc = 0; @@ -65,11 +65,10 @@ int cmd_tar_tree(int argc, const char **argv, const char *prefix) fprintf(stderr, "*** \"git tar-tree\" is now deprecated.\n" "*** Running \"git archive\" instead.\n***"); - for (i = 0; i < nargc; i++) { - fputc(' ', stderr); - sq_quote_print(stderr, nargv[i]); - } - fputc('\n', stderr); + sq_quote_argv(&sb, nargv, 0); + strbuf_addch(&sb, '\n'); + fputs(sb.buf, stderr); + strbuf_release(&sb); return cmd_archive(nargc, nargv, prefix); } |