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 <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Elijah Newren
2022-06-18 00:20:58 +00:00
committed by Junio C Hamano
parent de90581141
commit 7c48b27822
3 changed files with 62 additions and 5 deletions

View File

@ -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"),