diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-01-06 01:01:29 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-01-06 01:01:30 +0300 |
commit | bb14cfdfd74c37f4319405eaebce0691c5b51db0 (patch) | |
tree | ff830f599931dd6952e354ffd1ba0b2bedea8a76 /fmt-merge-msg.c | |
parent | a16548404789771fd3ee69f301893a08ef268bb2 (diff) | |
parent | bd2bc94252a47443e19d366f8cc9626d4f92df7a (diff) |
Merge branch 'jc/merge-detached-head-name'
The default merge message prepared by "git merge" records the name
of the current branch; the name can be overridden with a new option
to allow users to pretend a merge is made on a different branch.
* jc/merge-detached-head-name:
merge: allow to pretend a merge is made into a different branch
Diffstat (limited to 'fmt-merge-msg.c')
-rw-r--r-- | fmt-merge-msg.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c index e4f7810be2..e5c0aff2bf 100644 --- a/fmt-merge-msg.c +++ b/fmt-merge-msg.c @@ -650,12 +650,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); |