aboutsummaryrefslogtreecommitdiff
path: root/builtin/fmt-merge-msg.c
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2010-08-17 18:00:34 -0500
committerJunio C Hamano <gitster@pobox.com>2010-08-18 14:02:04 -0700
commit2102440c17f990fcb5c9269459c39c6312e80d1c (patch)
tree45f16b2b4e9ed80d31806f4a9acb4eb322172383 /builtin/fmt-merge-msg.c
parenta1e0ad78b784fd7c47c7bc2847f4813aca4cebaf (diff)
downloadgit-2102440c17f990fcb5c9269459c39c6312e80d1c.tar.gz
git-2102440c17f990fcb5c9269459c39c6312e80d1c.tar.xz
fmt-merge-msg -m to override merge title
Since v1.7.1.1~23^2 (merge: --log appends shortlog to message if specified, 2010-05-11), the fmt-merge-msg backend supports custom text to override the merge title "Merge <foo> into <bar>". Expose this functionality for scripted callers. Example: git fmt-merge-msg --log -m \ "$(printf '%s\n' \ "Merge branch 'api-cleanup' into feature" \ '' \ 'This is to use a few functions refactored for this purpose.' )" <.git/FETCH_HEAD Cc: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/fmt-merge-msg.c')
-rw-r--r--builtin/fmt-merge-msg.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index bc3c5e6d3..937d5a717 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -7,7 +7,7 @@
#include "string-list.h"
static const char * const fmt_merge_msg_usage[] = {
- "git fmt-merge-msg [--log|--no-log] [--file <file>]",
+ "git fmt-merge-msg [-m <message>] [--log|--no-log] [--file <file>]",
NULL
};
@@ -319,11 +319,14 @@ int fmt_merge_msg_shortlog(struct strbuf *in, struct strbuf *out) {
int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
{
const char *inpath = NULL;
+ const char *message = NULL;
struct option options[] = {
OPT_BOOLEAN(0, "log", &merge_summary, "populate log with the shortlog"),
{ OPTION_BOOLEAN, 0, "summary", &merge_summary, NULL,
"alias for --log (deprecated)",
PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
+ OPT_STRING('m', "message", &message, "text",
+ "use <text> as start of message"),
OPT_FILENAME('F', "file", &inpath, "file to read from"),
OPT_END()
};
@@ -337,6 +340,12 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
0);
if (argc > 0)
usage_with_options(fmt_merge_msg_usage, options);
+ if (message && !merge_summary) {
+ char nl = '\n';
+ write_in_full(STDOUT_FILENO, message, strlen(message));
+ write_in_full(STDOUT_FILENO, &nl, 1);
+ return 0;
+ }
if (inpath && strcmp(inpath, "-")) {
in = fopen(inpath, "r");
@@ -346,7 +355,12 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
if (strbuf_read(&input, fileno(in), 0) < 0)
die_errno("could not read input file");
- ret = fmt_merge_msg(merge_summary, &input, &output);
+ if (message) {
+ strbuf_addstr(&output, message);
+ ret = fmt_merge_msg_shortlog(&input, &output);
+ } else {
+ ret = fmt_merge_msg(merge_summary, &input, &output);
+ }
if (ret)
return ret;
write_in_full(STDOUT_FILENO, output.buf, output.len);