Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/merge-tree.c')
-rw-r--r--builtin/merge-tree.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 2332525d8b..831d9c7758 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -396,6 +396,7 @@ enum mode {
struct merge_tree_options {
int mode;
+ int show_messages;
};
static int real_merge(struct merge_tree_options *o,
@@ -435,18 +436,27 @@ static int real_merge(struct merge_tree_options *o,
merge_incore_recursive(&opt, merge_bases, parent1, parent2, &result);
if (result.clean < 0)
die(_("failure to merge"));
+
+ if (o->show_messages == -1)
+ o->show_messages = !result.clean;
+
puts(oid_to_hex(&result.tree->object.oid));
+ if (o->show_messages) {
+ printf("\n");
+ merge_display_update_messages(&opt, &result);
+ }
merge_finalize(&opt, &result);
return !result.clean; /* result.clean < 0 handled above */
}
int cmd_merge_tree(int argc, const char **argv, const char *prefix)
{
- struct merge_tree_options o = { 0 };
+ struct merge_tree_options o = { .show_messages = -1 };
int expected_remaining_argc;
+ int original_argc;
const char * const merge_tree_usage[] = {
- N_("git merge-tree [--write-tree] <branch1> <branch2>"),
+ N_("git merge-tree [--write-tree] [<options>] <branch1> <branch2>"),
N_("git merge-tree [--trivial-merge] <base-tree> <branch1> <branch2>"),
NULL
};
@@ -456,10 +466,13 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix)
MODE_REAL),
OPT_CMDMODE(0, "trivial-merge", &o.mode,
N_("do a trivial merge only"), MODE_TRIVIAL),
+ OPT_BOOL(0, "messages", &o.show_messages,
+ N_("also show informational/conflict messages")),
OPT_END()
};
/* Parse arguments */
+ original_argc = argc - 1; /* ignoring argv[0] */
argc = parse_options(argc, argv, prefix, mt_options,
merge_tree_usage, PARSE_OPT_STOP_AT_NON_OPTION);
switch (o.mode) {
@@ -483,8 +496,12 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix)
break;
case MODE_TRIVIAL:
expected_remaining_argc = 3;
+ /* Removal of `--trivial-merge` is expected */
+ original_argc--;
break;
}
+ if (o.mode == MODE_TRIVIAL && argc < original_argc)
+ die(_("--trivial-merge is incompatible with all other options"));
if (argc != expected_remaining_argc)
usage_with_options(merge_tree_usage, mt_options);