From b520bc6caa35e621396dd69ae4d84314615cf7ac Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Sat, 18 Jun 2022 00:20:53 +0000 Subject: merge-tree: provide easy access to `ls-files -u` style info Much like `git merge` updates the index with information of the form (mode, oid, stage, name) provide this output for conflicted files for merge-tree as well. Provide a --name-only option for users to exclude the mode, oid, and stage and only get the list of conflicted filenames. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- builtin/merge-tree.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'builtin/merge-tree.c') diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index 13a9536f7c..c61b5b4a10 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -400,6 +400,7 @@ enum mode { struct merge_tree_options { int mode; int show_messages; + int name_only; }; static int real_merge(struct merge_tree_options *o, @@ -453,7 +454,11 @@ static int real_merge(struct merge_tree_options *o, merge_get_conflicted_files(&result, &conflicted_files); for (i = 0; i < conflicted_files.nr; i++) { const char *name = conflicted_files.items[i].string; - if (last && !strcmp(last, name)) + struct stage_info *c = conflicted_files.items[i].util; + if (!o->name_only) + printf("%06o %s %d\t", + c->mode, oid_to_hex(&c->oid), c->stage); + else if (last && !strcmp(last, name)) continue; write_name_quoted_relative( name, prefix, stdout, line_termination); @@ -488,6 +493,10 @@ 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_BOOL_F(0, "name-only", + &o.name_only, + N_("list filenames without modes/oids/stages"), + PARSE_OPT_NONEG), OPT_END() }; -- cgit v1.2.3