From 7c48b27822b280222be1df7ec9f9e98d688f933b Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Sat, 18 Jun 2022 00:20:58 +0000 Subject: merge-tree: allow `ls-files -u` style info to be NUL terminated Much as `git ls-files` has a -z option, let's add one to merge-tree so that the conflict-info section can be NUL terminated (and avoid quoting of unusual filenames). Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- builtin/merge-tree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'builtin/merge-tree.c') diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index b3c5692498..c159e31774 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -445,7 +445,7 @@ static int real_merge(struct merge_tree_options *o, if (o->show_messages == -1) o->show_messages = !result.clean; - puts(oid_to_hex(&result.tree->object.oid)); + printf("%s%c", oid_to_hex(&result.tree->object.oid), line_termination); if (!result.clean) { struct string_list conflicted_files = STRING_LIST_INIT_NODUP; const char *last = NULL; @@ -494,6 +494,8 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix) N_("do a trivial merge only"), MODE_TRIVIAL), OPT_BOOL(0, "messages", &o.show_messages, N_("also show informational/conflict messages")), + OPT_SET_INT('z', NULL, &line_termination, + N_("separate paths with the NUL character"), '\0'), OPT_BOOL_F(0, "name-only", &o.name_only, N_("list filenames without modes/oids/stages"), -- cgit v1.2.3