Skip to content

Commit 7da2f28

Browse files
artagnongitster
authored andcommitted
tar-tree: remove dependency on sq_quote_print()
By rewriting the loop that formats the argv[] in cmd_tar_tree() function using sq_quote_argv() for code simplicity, the last use of sq_quote_print() goes away. Signed-off-by: Ramkumar Ramachandra <[email protected]> Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 10d0167 commit 7da2f28

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

builtin/tar-tree.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ int cmd_tar_tree(int argc, const char **argv, const char *prefix)
2626
* $0 tree-ish basedir ==>
2727
* git archive --format-tar --prefix=basedir tree-ish
2828
*/
29-
int i;
3029
const char **nargv = xcalloc(sizeof(*nargv), argc + 3);
30+
struct strbuf sb = STRBUF_INIT;
3131
char *basedir_arg;
3232
int nargc = 0;
3333

@@ -65,11 +65,10 @@ int cmd_tar_tree(int argc, const char **argv, const char *prefix)
6565
fprintf(stderr,
6666
"*** \"git tar-tree\" is now deprecated.\n"
6767
"*** Running \"git archive\" instead.\n***");
68-
for (i = 0; i < nargc; i++) {
69-
fputc(' ', stderr);
70-
sq_quote_print(stderr, nargv[i]);
71-
}
72-
fputc('\n', stderr);
68+
sq_quote_argv(&sb, nargv, 0);
69+
strbuf_addch(&sb, '\n');
70+
fputs(sb.buf, stderr);
71+
strbuf_release(&sb);
7372
return cmd_archive(nargc, nargv, prefix);
7473
}
7574

0 commit comments

Comments
 (0)