git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] tar-tree: remove dependency on sq_quote_print()

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Jul 30, 2013, 08:31 UTC
Message-ID
<1375173087-2164-3-git-send-email-artagnon@gmail.com>
In-Reply-To
<1375173087-2164-1-git-send-email-artagnon@gmail.com>

Currently, there is exactly one caller of sq_quote_print(), namely cmd_tar_tree(). In the interest of removing sq_quote_print() and simplification, replace it with an equivalent call to sq_quote_argv(). No functional changes intended.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/tar-tree.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/builtin/tar-tree.c b/builtin/tar-tree.c
index 3f1e701..ba3ffe6 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);
 }
 
-- 
1.8.4.rc0.4.g4634265
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 3 of 7 in “Remove sq_quote_print() in favor of *_buf”
  1. 0/3 Remove sq_quote_print() in favor of *_bufRamkumar Ramachandra, Jul 30, 2013
  2. 1/3 for-each-ref, quote: convert *_quote_print -> *_quote_bufRamkumar Ramachandra, Jul 30, 2013
  3. 2/3 tar-tree: remove dependency on sq_quote_print()Ramkumar Ramachandra, Jul 30, 2013
  4. 3/3 quote: remove sq_quote_print()Ramkumar Ramachandra, Jul 30, 2013
  5. Junio C HamanoJul 30, 2013
  6. Junio C HamanoJul 30, 2013
  7. Ramkumar RamachandraJul 30, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.