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 --- fmt-merge-msg.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'fmt-merge-msg.c') diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c index 5216191488..d25594545c 100644 --- a/fmt-merge-msg.c +++ b/fmt-merge-msg.c @@ -649,12 +649,15 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out, memset(&merge_parents, 0, sizeof(merge_parents)); - /* get current branch */ + /* learn the commit that we merge into and the current branch name */ current_branch = current_branch_to_free = resolve_refdup("HEAD", RESOLVE_REF_READING, &head_oid, NULL); if (!current_branch) die("No current branch"); - if (starts_with(current_branch, "refs/heads/")) + + if (opts->into_name) + current_branch = opts->into_name; + else if (starts_with(current_branch, "refs/heads/")) current_branch += 11; find_merge_parents(&merge_parents, in, &head_oid); -- cgit v1.2.3