merge: --log appends shortlog to message if specified
When the user specifies a message, use fmt_merge_msg_shortlog() to
append the shortlog.
Previously, when a message was specified, we ignored the merge title
("Merge <foo> into <bar>") and shortlog from fmt_merge_msg().
Update the documentation for -m to reflect this too.
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
8c6bdfdf8b
commit
f0ecac2b70
@@ -58,7 +58,12 @@ include::merge-options.txt[]
|
|||||||
|
|
||||||
-m <msg>::
|
-m <msg>::
|
||||||
Set the commit message to be used for the merge commit (in
|
Set the commit message to be used for the merge commit (in
|
||||||
case one is created). The 'git fmt-merge-msg' command can be
|
case one is created).
|
||||||
|
|
||||||
|
If `--log` is specified, a shortlog of the commits being merged
|
||||||
|
will be appended to the specified message.
|
||||||
|
|
||||||
|
The 'git fmt-merge-msg' command can be
|
||||||
used to give a good default for automated 'git merge'
|
used to give a good default for automated 'git merge'
|
||||||
invocations.
|
invocations.
|
||||||
|
|
||||||
|
|||||||
@@ -298,6 +298,9 @@ static int do_fmt_merge_msg(int merge_title, int merge_summary,
|
|||||||
rev.ignore_merges = 1;
|
rev.ignore_merges = 1;
|
||||||
rev.limited = 1;
|
rev.limited = 1;
|
||||||
|
|
||||||
|
if (suffixcmp(out->buf, "\n"))
|
||||||
|
strbuf_addch(out, '\n');
|
||||||
|
|
||||||
for (i = 0; i < origins.nr; i++)
|
for (i = 0; i < origins.nr; i++)
|
||||||
shortlog(origins.items[i].string, origins.items[i].util,
|
shortlog(origins.items[i].string, origins.items[i].util,
|
||||||
head, &rev, limit, out);
|
head, &rev, limit, out);
|
||||||
|
|||||||
@@ -981,19 +981,23 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
|
|||||||
/*
|
/*
|
||||||
* All the rest are the commits being merged;
|
* All the rest are the commits being merged;
|
||||||
* prepare the standard merge summary message to
|
* prepare the standard merge summary message to
|
||||||
* used as the merge message. If remote
|
* be appended to the given message. If remote
|
||||||
* is invalid we will die later in the common
|
* is invalid we will die later in the common
|
||||||
* codepath so we discard the error in this
|
* codepath so we discard the error in this
|
||||||
* loop.
|
* loop.
|
||||||
*/
|
*/
|
||||||
if (!have_message) {
|
|
||||||
for (i = 0; i < argc; i++)
|
for (i = 0; i < argc; i++)
|
||||||
merge_name(argv[i], &merge_names);
|
merge_name(argv[i], &merge_names);
|
||||||
|
|
||||||
|
if (have_message && option_log)
|
||||||
|
fmt_merge_msg_shortlog(&merge_names, &merge_msg);
|
||||||
|
else if (!have_message)
|
||||||
fmt_merge_msg(option_log, &merge_names, &merge_msg);
|
fmt_merge_msg(option_log, &merge_names, &merge_msg);
|
||||||
if (merge_msg.len)
|
|
||||||
|
|
||||||
|
if (!(have_message && !option_log) && merge_msg.len)
|
||||||
strbuf_setlen(&merge_msg, merge_msg.len-1);
|
strbuf_setlen(&merge_msg, merge_msg.len-1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (head_invalid || !argc)
|
if (head_invalid || !argc)
|
||||||
usage_with_options(builtin_merge_usage,
|
usage_with_options(builtin_merge_usage,
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ test_expect_success 'merge c2 with a custom message' '
|
|||||||
test_cmp exp.subject actual
|
test_cmp exp.subject actual
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_failure 'merge --log appends to custom message' '
|
test_expect_success 'merge --log appends to custom message' '
|
||||||
git reset --hard c1 &&
|
git reset --hard c1 &&
|
||||||
git merge --log -m "$(cat exp.subject)" c2 &&
|
git merge --log -m "$(cat exp.subject)" c2 &&
|
||||||
git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
|
git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
|
||||||
|
|||||||
Reference in New Issue
Block a user