diff mbox series

[v2,3/4] fast-export: refactor path printing to not rely on stdout

Message ID 20200622214805.GC3303964@coredump.intra.peff.net (mailing list archive)
State New, archived
Headers show
Series fast-export: allow dumping anonymization mappings | expand

Commit Message

Jeff King June 22, 2020, 9:48 p.m. UTC
We'll be using print_path_1() in more places in a subsequent patch, so
let's teach it to take the output handle as a parameter.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/fast-export.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index faaab6c7e9..aa7ac9761d 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -369,15 +369,15 @@  static int depth_first(const void *a_, const void *b_)
 	return (a->status == 'R') - (b->status == 'R');
 }
 
-static void print_path_1(const char *path)
+static void print_path_1(FILE *out, const char *path)
 {
 	int need_quote = quote_c_style(path, NULL, NULL, 0);
 	if (need_quote)
-		quote_c_style(path, NULL, stdout, 0);
+		quote_c_style(path, NULL, out, 0);
 	else if (strchr(path, ' '))
-		printf("\"%s\"", path);
+		fprintf(out, "\"%s\"", path);
 	else
-		printf("%s", path);
+		fprintf(out, "%s", path);
 }
 
 static void *anonymize_path_component(const void *path, size_t *len)
@@ -391,13 +391,13 @@  static void *anonymize_path_component(const void *path, size_t *len)
 static void print_path(const char *path)
 {
 	if (!anonymize)
-		print_path_1(path);
+		print_path_1(stdout, path);
 	else {
 		static struct hashmap paths;
 		static struct strbuf anon = STRBUF_INIT;
 
 		anonymize_path(&anon, path, &paths, anonymize_path_component);
-		print_path_1(anon.buf);
+		print_path_1(stdout, anon.buf);
 		strbuf_reset(&anon);
 	}
 }