From: Jonathan Nieder <jrnieder@gmail.com>
To: git@vger.kernel.org
Cc: Lars Hjemli <hjemli@gmail.com>, Tay Ray Chuan <rctay89@gmail.com>,
Matthieu Moy <Matthieu.Moy@imag.fr>,
Clemens Buchacher <drizzd@aon.at>, Jeff King <peff@peff.net>
Subject: [PATCH 11/24 v2] fmt-merge-msg -m to override merge title
Date: Tue, 17 Aug 2010 18:00:34 -0500 [thread overview]
Message-ID: <20100817230034.GG2221@burratino> (raw)
In-Reply-To: <20100817070245.GK22057@burratino>
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>
---
Jonathan Nieder wrote:
> +'git fmt-merge-msg' [-m <subject>] [--log ]| --no-log] -F <file>
Oops.
> +-m <subject>::
> +--message <subject>::
Since the message is used to start the body of the message in
addition to the subject, the generic word <message> seems clearer.
> - "git fmt-merge-msg [--log|--no-log] [--file <file>]",
> + "git fmt-merge-msg [-m <online>] [--log|--no-log] [--file <file>]",
Likewise.
> + OPT_STRING('m', "message", &oneline_msg, "oneline",
> + "use <oneline> as subject line"),
Likewise.
Documentation/git-fmt-merge-msg.txt | 9 +++++++--
builtin/fmt-merge-msg.c | 18 ++++++++++++++++--
t/t6200-fmt-merge-msg.sh | 32 ++++++++++++++++++++++++++++++++
3 files changed, 55 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-fmt-merge-msg.txt b/Documentation/git-fmt-merge-msg.txt
index a585dbe..302f56b 100644
--- a/Documentation/git-fmt-merge-msg.txt
+++ b/Documentation/git-fmt-merge-msg.txt
@@ -9,8 +9,8 @@ git-fmt-merge-msg - Produce a merge commit message
SYNOPSIS
--------
[verse]
-'git fmt-merge-msg' [--log | --no-log] <$GIT_DIR/FETCH_HEAD
-'git fmt-merge-msg' [--log | --no-log] -F <file>
+'git fmt-merge-msg' [-m <message>] [--log | --no-log] <$GIT_DIR/FETCH_HEAD
+'git fmt-merge-msg' [-m <message>] [--log | --no-log] -F <file>
DESCRIPTION
-----------
@@ -38,6 +38,11 @@ OPTIONS
Synonyms to --log and --no-log; these are deprecated and will be
removed in the future.
+-m <message>::
+--message <message>::
+ Use <message> instead of the branch names for the first line
+ of the log message. For use with `--log`.
+
-F <file>::
--file <file>::
Take the list of merged objects from <file> instead of
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index bc3c5e6..937d5a7 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);
diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh
index 5553dff..71f6cad 100755
--- a/t/t6200-fmt-merge-msg.sh
+++ b/t/t6200-fmt-merge-msg.sh
@@ -129,6 +129,38 @@ test_expect_success '[merge] summary/log configuration' '
test_cmp expected actual2
'
+test_expect_success 'fmt-merge-msg -m' '
+ echo "Sync with left" >expected &&
+ cat >expected.log <<-EOF &&
+ Sync with left
+
+ * ${apos}left${apos} of $(pwd):
+ Left #5
+ Left #4
+ Left #3
+ Common #2
+ Common #1
+ EOF
+
+ test_might_fail git config --unset merge.log &&
+ test_might_fail git config --unset merge.summary &&
+ git checkout master &&
+ git fetch "$(pwd)" left &&
+ git fmt-merge-msg -m "Sync with left" <.git/FETCH_HEAD >actual &&
+ git fmt-merge-msg --log -m "Sync with left" \
+ <.git/FETCH_HEAD >actual.log &&
+ git config merge.log true &&
+ git fmt-merge-msg -m "Sync with left" \
+ <.git/FETCH_HEAD >actual.log-config &&
+ git fmt-merge-msg --no-log -m "Sync with left" \
+ <.git/FETCH_HEAD >actual.nolog &&
+
+ test_cmp expected actual &&
+ test_cmp expected.log actual.log &&
+ test_cmp expected.log actual.log-config &&
+ test_cmp expected actual.nolog
+'
+
test_expect_success 'setup: expected shortlog for two branches' '
cat >expected <<-EOF
Merge branches ${apos}left${apos} and ${apos}right${apos}
--
1.7.2.1.544.ga752d.dirty
next prev parent reply other threads:[~2010-08-17 23:02 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-17 6:51 [PATCH/RFC] updating examples/git-merge (plus a builtin/merge fix) Jonathan Nieder
2010-08-17 6:52 ` [PATCH 01/24] merge: do not mistake (ancestor of) tag for branch Jonathan Nieder
2010-08-17 6:53 ` [PATCH 02/24] t7600 (merge): modernize style Jonathan Nieder
2010-08-17 6:54 ` [PATCH 03/24] t7600 (merge): do not launch gitk for --debug Jonathan Nieder
2010-08-17 7:31 ` Ævar Arnfjörð Bjarmason
2010-08-17 17:50 ` Sverre Rabbelier
2010-08-18 2:29 ` Jonathan Nieder
2010-08-18 8:55 ` Ævar Arnfjörð Bjarmason
2010-08-18 10:44 ` Jonathan Nieder
2010-08-17 6:56 ` [PATCH 04/24] t7600 (merge): check reflog entry Jonathan Nieder
2010-08-17 6:56 ` [PATCH 05/24] t7600 (merge): test merge from branch yet to be born Jonathan Nieder
2010-08-17 6:57 ` [PATCH 06/24] t6010 (merge-base): modernize style Jonathan Nieder
2010-08-17 6:57 ` [PATCH 07/24] t6200 (fmt-merge-msg): style nitpicks Jonathan Nieder
2010-08-17 6:59 ` [PATCH 08/24] Documentation: add a SEE ALSO section for merge-base Jonathan Nieder
2010-08-17 7:01 ` [PATCH 09/24] merge-base --octopus to mimic show-branch --merge-base Jonathan Nieder
2010-08-17 7:01 ` [PATCH 10/24] merge-base --independent to print reduced parent list in a merge Jonathan Nieder
2010-08-17 7:02 ` [PATCH 11/24] fmt-merge-msg -m to override subject line Jonathan Nieder
2010-08-17 23:00 ` Jonathan Nieder [this message]
2010-08-17 7:03 ` [PATCH 12/24] merge script: --squash, --ff from unborn branch are errors Jonathan Nieder
2010-08-17 7:03 ` [PATCH 13/24] merge script: tweak unmerged files message to match builtin Jonathan Nieder
2010-08-17 7:36 ` Ævar Arnfjörð Bjarmason
2010-08-17 7:03 ` [PATCH 14/24] merge script: refuse to merge during merge Jonathan Nieder
2010-08-17 7:04 ` [PATCH 15/24] merge script: improve log message subject Jonathan Nieder
2010-08-17 7:05 ` [PATCH 16/24] merge script: merge -X<option> Jonathan Nieder
2010-08-17 7:05 ` [PATCH 17/24] merge script: allow custom strategies Jonathan Nieder
2010-08-17 7:06 ` [PATCH 18/24] merge script: forbid merge -s index Jonathan Nieder
2010-08-17 7:06 ` [PATCH 19/24] merge script: handle -m --log correctly Jonathan Nieder
2010-08-17 9:55 ` Tay Ray Chuan
2010-08-17 21:54 ` Jonathan Nieder
2010-08-17 7:09 ` [PATCH 20/24] merge script: handle many-way octopus Jonathan Nieder
2010-08-17 7:10 ` [PATCH 21/24] merge script: --ff-only to disallow true merge Jonathan Nieder
2010-08-17 7:11 ` [PATCH 22/24] merge script: handle --no-ff --no-commit correctly Jonathan Nieder
2010-08-17 7:11 ` [PATCH 23/24] merge script: notice @{-1} shorthand Jonathan Nieder
2010-08-17 7:13 ` [PATCH 24/24] merge script: learn --[no-]rerere-autoupdate Jonathan Nieder
2010-08-17 7:46 ` [PATCH/RFC] updating examples/git-merge (plus a builtin/merge fix) Ævar Arnfjörð Bjarmason
2010-08-17 8:10 ` Jonathan Nieder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100817230034.GG2221@burratino \
--to=jrnieder@gmail.com \
--cc=Matthieu.Moy@imag.fr \
--cc=drizzd@aon.at \
--cc=git@vger.kernel.org \
--cc=hjemli@gmail.com \
--cc=peff@peff.net \
--cc=rctay89@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).