From bd2bc94252a47443e19d366f8cc9626d4f92df7a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 20 Dec 2021 14:53:43 -0800 Subject: merge: allow to pretend a merge is made into a different branch When a series of patches for a topic-B depends on having topic-A, the workflow to prepare the topic-B branch would look like this: $ git checkout -b topic-B main $ git merge --no-ff --no-edit topic-A $ git am " option to "git merge" and its underlying "git fmt-merge-message", to pretend as if we were merging into , no matter what branch we are actually merging into, when they prepare the merge message. The pretend name honors the usual "into " suppression mechanism, which can be seen in the tests added here. Signed-off-by: Junio C Hamano --- builtin/merge.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'builtin/merge.c') diff --git a/builtin/merge.c b/builtin/merge.c index ea3112e0c0..1ba5951d49 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -87,6 +87,7 @@ static int signoff; static const char *sign_commit; static int autostash; static int no_verify; +static char *into_name; static struct strategy all_strategy[] = { { "recursive", NO_TRIVIAL }, @@ -286,6 +287,8 @@ static struct option builtin_merge_options[] = { { OPTION_LOWLEVEL_CALLBACK, 'F', "file", &merge_msg, N_("path"), N_("read message from file"), PARSE_OPT_NONEG, NULL, 0, option_read_message }, + OPT_STRING(0, "into-name", &into_name, N_("name"), + N_("use instead of the real target")), OPT__VERBOSITY(&verbosity), OPT_BOOL(0, "abort", &abort_current_merge, N_("abort the current in-progress merge")), @@ -1122,6 +1125,7 @@ static void prepare_merge_message(struct strbuf *merge_names, struct strbuf *mer opts.add_title = !have_message; opts.shortlog_len = shortlog_len; opts.credit_people = (0 < option_edit); + opts.into_name = into_name; fmt_merge_msg(merge_names, merge_msg, &opts); if (merge_msg->len) -- cgit v1.2.3