Skip to contentSkip to conversation

merge --log configurability

PATCH Superseded Ramkumar Ramachandra 3 participants 13 messages Jun 15, 2016 Documentation

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover merge --log configurability

This series is a complete rewrite after Jonathan's last review. I've tried to pay close attention to detail and be as careful as possible- let me know if I've missed something.

Thanks.

Jonathan Nieder (1):
parse-options: clarify PARSE_OPT_NOARG description

Ramkumar Ramachandra (4):
fmt_merge_msg: Change fmt_merge_msg API to accept shortlog_len
merge: Make '--log' an integer option for number of shortlog entries
merge: Make 'merge.log' an integer or boolean option
fmt-merge-msg: Remove deprecated '--summary' option

 Documentation/git-fmt-merge-msg.txt |   23 +++++----------
 Documentation/merge-config.txt      |    8 ++++-
 Documentation/merge-options.txt     |   11 ++-----
 builtin.h                           |    5 +--
 builtin/fmt-merge-msg.c             |   49 ++++++++++++++++------------------
 builtin/merge.c                     |   25 +++++++++++------
 parse-options.h                     |    2 +-
 7 files changed, 59 insertions(+), 64 deletions(-)
Signature · 1 line
1.7.2.2.409.gdbb11.dirty
#1 lore raw

PATCH v5 1/5 fmt_merge_msg: Change fmt_merge_msg API to accept shortlog_len

Update the API of the fmt_merge_msg function to replace the the merge_summary argument with a new shortlog_len argument. Update the callers track this change: when translating from merge_summary to shortlog_len, note that 0 means no shortlog and 20 is the default "enabled" value.

Thanks-to: Jonathan Nieder <[email protected]>

---
 builtin.h               |    5 ++---
 builtin/fmt-merge-msg.c |   24 +++++++++++-------------
 builtin/merge.c         |    5 +++--
 3 files changed, 16 insertions(+), 18 deletions(-)
builtin.h +2 -3
index 9c3d50b..1993166 100644
@@ -14,9 +14,8 @@ extern const char git_more_info_string[];
 extern void list_common_cmds_help(void);
 extern const char *help_unknown_cmd(const char *cmd);
 extern void prune_packed_objects(int);
-extern int fmt_merge_msg(int merge_summary, struct strbuf *in,
-	struct strbuf *out);
-extern int fmt_merge_msg_shortlog(struct strbuf *in, struct strbuf *out);
+extern int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
+			 int merge_title, int shortlog_len);
 extern int commit_notes(struct notes_tree *t, const char *msg);
 
 struct notes_rewrite_cfg {
builtin/fmt-merge-msg.c +11 -13
index e7e12ee..4ed728a 100644
@@ -255,9 +255,9 @@ static void do_fmt_merge_msg_title(struct strbuf *out,
 		strbuf_addf(out, " into %s\n", current_branch);
 }
 
-static int do_fmt_merge_msg(int merge_title, int merge_summary,
-	struct strbuf *in, struct strbuf *out) {
-	int limit = 20, i = 0, pos = 0;
+static int do_fmt_merge_msg(int merge_title, struct strbuf *in,
+	struct strbuf *out, int shortlog_len) {
+	int i = 0, pos = 0;
 	unsigned char head_sha1[20];
 	const char *current_branch;
 
@@ -288,7 +288,7 @@ static int do_fmt_merge_msg(int merge_title, int merge_summary,
 	if (merge_title)
 		do_fmt_merge_msg_title(out, current_branch);
 
-	if (merge_summary) {
+	if (shortlog_len) {
 		struct commit *head;
 		struct rev_info rev;
 
@@ -303,17 +303,14 @@ static int do_fmt_merge_msg(int merge_title, int merge_summary,
 
 		for (i = 0; i < origins.nr; i++)
 			shortlog(origins.items[i].string, origins.items[i].util,
-					head, &rev, limit, out);
+					head, &rev, shortlog_len, out);
 	}
 	return 0;
 }
 
-int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
-	return do_fmt_merge_msg(1, merge_summary, in, out);
-}
-
-int fmt_merge_msg_shortlog(struct strbuf *in, struct strbuf *out) {
-	return do_fmt_merge_msg(0, 1, in, out);
+int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
+		  int merge_title, int shortlog_len) {
+	return do_fmt_merge_msg(merge_title, in, out, shortlog_len);
 }
 
 int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
@@ -357,9 +354,10 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
 		die_errno("could not read input file");
 	if (message) {
 		strbuf_addstr(&output, message);
-		ret = fmt_merge_msg_shortlog(&input, &output);
+		ret = fmt_merge_msg(&input, &output, 0, 20);
 	} else {
-		ret = fmt_merge_msg(merge_summary, &input, &output);
+		ret = fmt_merge_msg(&input, &output, 1,
+				    merge_summary ? 20 : 0);
 	}
 	if (ret)
 		return ret;
builtin/merge.c +3 -2
index 4e4ec89..d47f48f 100644
@@ -1014,9 +1014,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 			merge_name(argv[i], &merge_names);
 
 		if (have_message && option_log)
-			fmt_merge_msg_shortlog(&merge_names, &merge_msg);
+			fmt_merge_msg(&merge_names, &merge_msg, 0, 20);
 		else if (!have_message)
-			fmt_merge_msg(option_log, &merge_names, &merge_msg);
+			fmt_merge_msg(&merge_names, &merge_msg, 1,
+				      option_log ? 20: 0);
 
 
 		if (!(have_message && !option_log) && merge_msg.len)
Signature · 1 line
1.7.2.2.409.gdbb11.dirty
Reviewed-by on v5 1/5
#2 lore raw

Re: [PATCH v5 1/5] fmt_merge_msg: Change fmt_merge_msg API to accept shortlog_len

Quoted 2 lines · Ramkumar Ramachandra

Update the API of the fmt_merge_msg function to replace the the merge_summary argument with a new shortlog_len argument.

Even more, actually:

Review extern const char git_more_info_string[]; · line 18

Quoted 10 lines

+++ b/builtin.h

(quoted diff) +2 -3
@@ -14,9 +14,8 @@ extern const char git_more_info_string[];
 extern void list_common_cmds_help(void);
 extern const char *help_unknown_cmd(const char *cmd);
 extern void prune_packed_objects(int);
-extern int fmt_merge_msg(int merge_summary, struct strbuf *in,
-	struct strbuf *out);
-extern int fmt_merge_msg_shortlog(struct strbuf *in, struct strbuf *out);
+extern int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
+			 int merge_title, int shortlog_len);

This combines the public functions. Nice, but probably worth a mention in the log message.

The API does not make the sense of the merge_title argument clear:
should it be 1 when the caller provides a title or when fmt_merge_msg should provide one? There is not much I can see to do about that; I'd just suggest making it clear in the commit message (so it can be mentioned in the API docs, once they're written :)).

Review int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix) · line 360

Quoted 10 lines
(quoted diff) +3 -2
@@ -357,9 +354,10 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
 		die_errno("could not read input file");
 	if (message) {
 		strbuf_addstr(&output, message);
-		ret = fmt_merge_msg_shortlog(&input, &output);
+		ret = fmt_merge_msg(&input, &output, 0, 20);
 	} else {
-		ret = fmt_merge_msg(merge_summary, &input, &output);
+		ret = fmt_merge_msg(&input, &output, 1,
+				    merge_summary ? 20 : 0);

Could be further simplified:

	if (message)
		strbuf_addstr(&output, message);
	ret = fmt_merge_msg(&input, &output,
				message ? 0 : 1,
				merge_summary ? 20 : 0);

Not sure if that helps or not.

A part of me wishes that the constant 20 wouldn't be duplicated so much. Would something like

	#define DEFAULT_MERGE_SHORTLOG_LEN 20

make sense?

Review int cmd_merge(int argc, const char **argv, const char *prefix) · line 1020

Quoted 11 lines
(quoted diff) +4 -2
+++ b/builtin/merge.c
@@ -1014,9 +1014,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 			merge_name(argv[i], &merge_names);
 
 		if (have_message && option_log)
-			fmt_merge_msg_shortlog(&merge_names, &merge_msg);
+			fmt_merge_msg(&merge_names, &merge_msg, 0, 20);
 		else if (!have_message)
-			fmt_merge_msg(option_log, &merge_names, &merge_msg);
+			fmt_merge_msg(&merge_names, &merge_msg, 1,
+				      option_log ? 20: 0);

Likewise.

The rest looks good. So except for the commit message,

Thanks.

Here are the cleanups I mentioned. Except for the #define, they probably don't belong in this patch.
---

builtin.h +2 -0
index 7d18106..09b94ea 100644
@@ -7,6 +7,8 @@
 #include "commit.h"
 #include "notes.h"
 
+#define DEFAULT_MERGE_LOG_LEN 20
+
 extern const char git_version_string[];
 extern const char git_usage_string[];
 extern const char git_more_info_string[];
builtin/fmt-merge-msg.c +6 -6
index 4ed728a..7f06b95 100644
@@ -352,13 +352,13 @@ 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");
-	if (message) {
+
+	if (message)
 		strbuf_addstr(&output, message);
-		ret = fmt_merge_msg(&input, &output, 0, 20);
-	} else {
-		ret = fmt_merge_msg(&input, &output, 1,
-				    merge_summary ? 20 : 0);
-	}
+	ret = fmt_merge_msg(&input, &output,
+			    message ? 0 : 1,
+			    merge_summary ? DEFAULT_MERGE_LOG_LEN : 0);
+
 	if (ret)
 		return ret;
 	write_in_full(STDOUT_FILENO, output.buf, output.len);
builtin/merge.c +6 -9
index 70ee412..d797853 100644
@@ -1000,15 +1000,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		for (i = 0; i < argc; i++)
 			merge_name(argv[i], &merge_names);
 
-		if (have_message && option_log)
-			fmt_merge_msg(&merge_names, &merge_msg, 0, 20);
-		else if (!have_message)
-			fmt_merge_msg(&merge_names, &merge_msg, 1,
-				      option_log ? 20: 0);
-
-
-		if (!(have_message && !option_log) && merge_msg.len)
-			strbuf_setlen(&merge_msg, merge_msg.len-1);
+		if (!have_message || option_log) {
+			fmt_merge_msg(&merge_names, &merge_msg, !have_message,
+				      option_log ? DEFAULT_MERGE_LOG_LEN : 0);
+			if (merge_msg.len)
+				strbuf_setlen(&merge_msg, merge_msg.len - 1);
+		}
 	}
 
 	if (head_invalid || !argc)
#3 lore raw

Re: [PATCH v5 1/5] fmt_merge_msg: Change fmt_merge_msg API to accept shortlog_len

Quoted 3 lines · Jonathan Nieder

The rest looks good. So except for the commit message,

Thanks; all of your comments make sense. Here is what I'll queue.

-- >8 --
From: Ramkumar Ramachandra <[email protected]>
Date: Sun, 22 Aug 2010 21:56:34 +0530
Subject: [PATCH] fmt_merge_msg: Change fmt_merge_msg API to accept shortlog_len

Give "shortlog_len" parameter to the fmt_merge_msg(), remove its "merge_summary" parameter, and remove fmt_merge_msg_shortlog() function. In the updated API, shortlog_len == 0 means no shortlog is given.

The parameter "merge_title" controls if the title of the merge commit is autogenerated (it reads something like "Merge branch ..."), and typically it is set to true when the caller does not give its own message.

---
 builtin.h               |    7 ++++---
 builtin/fmt-merge-msg.c |   30 ++++++++++++++----------------
 builtin/merge.c         |   14 ++++++--------
 3 files changed, 24 insertions(+), 27 deletions(-)
builtin.h +4 -3
index ed6ee26..09b94ea 100644
@@ -7,6 +7,8 @@
 #include "commit.h"
 #include "notes.h"
 
+#define DEFAULT_MERGE_LOG_LEN 20
+
 extern const char git_version_string[];
 extern const char git_usage_string[];
 extern const char git_more_info_string[];
@@ -14,9 +16,8 @@ extern const char git_more_info_string[];
 extern void list_common_cmds_help(void);
 extern const char *help_unknown_cmd(const char *cmd);
 extern void prune_packed_objects(int);
-extern int fmt_merge_msg(int merge_summary, struct strbuf *in,
-	struct strbuf *out);
-extern int fmt_merge_msg_shortlog(struct strbuf *in, struct strbuf *out);
+extern int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
+			 int merge_title, int shortlog_len);
 extern int commit_notes(struct notes_tree *t, const char *msg);
 
 struct notes_rewrite_cfg {
builtin/fmt-merge-msg.c +14 -16
index 937d5a7..42021d3 100644
@@ -255,9 +255,9 @@ static void do_fmt_merge_msg_title(struct strbuf *out,
 		strbuf_addf(out, " into %s\n", current_branch);
 }
 
-static int do_fmt_merge_msg(int merge_title, int merge_summary,
-	struct strbuf *in, struct strbuf *out) {
-	int limit = 20, i = 0, pos = 0;
+static int do_fmt_merge_msg(int merge_title, struct strbuf *in,
+	struct strbuf *out, int shortlog_len) {
+	int i = 0, pos = 0;
 	unsigned char head_sha1[20];
 	const char *current_branch;
 
@@ -288,7 +288,7 @@ static int do_fmt_merge_msg(int merge_title, int merge_summary,
 	if (merge_title)
 		do_fmt_merge_msg_title(out, current_branch);
 
-	if (merge_summary) {
+	if (shortlog_len) {
 		struct commit *head;
 		struct rev_info rev;
 
@@ -303,17 +303,14 @@ static int do_fmt_merge_msg(int merge_title, int merge_summary,
 
 		for (i = 0; i < origins.nr; i++)
 			shortlog(origins.items[i].string, origins.items[i].util,
-					head, &rev, limit, out);
+					head, &rev, shortlog_len, out);
 	}
 	return 0;
 }
 
-int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
-	return do_fmt_merge_msg(1, merge_summary, in, out);
-}
-
-int fmt_merge_msg_shortlog(struct strbuf *in, struct strbuf *out) {
-	return do_fmt_merge_msg(0, 1, in, out);
+int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
+		  int merge_title, int shortlog_len) {
+	return do_fmt_merge_msg(merge_title, in, out, shortlog_len);
 }
 
 int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
@@ -355,12 +352,13 @@ 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");
-	if (message) {
+
+	if (message)
 		strbuf_addstr(&output, message);
-		ret = fmt_merge_msg_shortlog(&input, &output);
-	} else {
-		ret = fmt_merge_msg(merge_summary, &input, &output);
-	}
+	ret = fmt_merge_msg(&input, &output,
+			    message ? 0 : 1,
+			    merge_summary ? DEFAULT_MERGE_LOG_LEN : 0);
+
 	if (ret)
 		return ret;
 	write_in_full(STDOUT_FILENO, output.buf, output.len);
builtin/merge.c +6 -8
index 2207f79..b2c0984 100644
@@ -998,14 +998,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		for (i = 0; i < argc; i++)
 			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);
-
-
-		if (!(have_message && !option_log) && merge_msg.len)
-			strbuf_setlen(&merge_msg, merge_msg.len-1);
+		if (!have_message || option_log) {
+			fmt_merge_msg(&merge_names, &merge_msg, !have_message,
+				      option_log ? DEFAULT_MERGE_LOG_LEN : 0);
+			if (merge_msg.len)
+				strbuf_setlen(&merge_msg, merge_msg.len - 1);
+		}
 	}
 
 	if (head_invalid || !argc)
Signature · 1 line
1.7.2.2.426.g2251a
#4 lore raw

PATCH 1/1 merge, fmt_merge_msg --log: default value is DEFAULT_MERGE_LOG_LEN

Most references to the DEFAULT_MERGE_LOG_LEN were changed to use that symbolic constant, but a few uses of hardcoded "20" remain.

Cc Ramkumar Ramachandra <[email protected]>

---
Noticed this while looking over ab6beee (merge: Make '--log' an integer option) from pu. Maybe something like it could be squashed in in the next round.

builtin/fmt-merge-msg.c +3 -2
index 425900d..bc7c30f 100644
@@ -323,10 +323,11 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
 	struct option options[] = {
 		{ OPTION_INTEGER, 0, "log", &shortlog_len, "n",
 		  "populate log with <n> entries from shortlog",
-		  PARSE_OPT_OPTARG, NULL, 20 },
+		  PARSE_OPT_OPTARG, NULL, DEFAULT_MERGE_LOG_LEN },
 		{ OPTION_INTEGER, 0, "summary", &shortlog_len, "n",
 		  "alias for --log (deprecated)",
-		  PARSE_OPT_OPTARG | PARSE_OPT_HIDDEN, NULL, 20 },
+		  PARSE_OPT_OPTARG | PARSE_OPT_HIDDEN, NULL,
+		  DEFAULT_MERGE_LOG_LEN },
 		OPT_STRING('m', "message", &message, "text",
 			"use <text> as start of message"),
 		OPT_FILENAME('F', "file", &inpath, "file to read from"),
builtin/merge.c +1 -1
index bf550a6..9e4733d 100644
@@ -177,7 +177,7 @@ static struct option builtin_merge_options[] = {
 	OPT_BOOLEAN(0, "summary", &show_diffstat, "(synonym to --stat)"),
 	{ OPTION_INTEGER, 0, "log", &shortlog_len, "n",
 	  "add (at most <n>) entries from shortlog to merge commit message",
-	  PARSE_OPT_OPTARG, NULL, 20 },
+	  PARSE_OPT_OPTARG, NULL, DEFAULT_MERGE_LOG_LEN },
 	OPT_BOOLEAN(0, "squash", &squash,
 		"create a single commit instead of doing a merge"),
 	OPT_BOOLEAN(0, "commit", &option_commit,
#5 lore raw

PATCH v5 2/5 merge: Make '--log' an integer option for number of shortlog entries

In reply to Ramkumar Ramachandra

Change the command-line '--log' option from a boolean option to an integer option, and parse the optional integer provided on the command-line into the 'shortlog_len' variable. Also update the documentation accordingly.

Thanks-to: Jonathan Nieder <[email protected]>
Thanks-to: Johannes Sixt <[email protected]>

---
 Documentation/git-fmt-merge-msg.txt |   10 +++++-----
 Documentation/merge-options.txt     |    6 +++---
 builtin/fmt-merge-msg.c             |   25 ++++++++++++++-----------
 builtin/merge.c                     |   18 ++++++++++--------
 4 files changed, 32 insertions(+), 27 deletions(-)
Documentation/git-fmt-merge-msg.txt +5 -5
index 302f56b..14ac466 100644
@@ -9,8 +9,8 @@ git-fmt-merge-msg - Produce a merge commit message
 SYNOPSIS
 --------
 [verse]
-'git fmt-merge-msg' [-m <message>] [--log | --no-log] <$GIT_DIR/FETCH_HEAD
-'git fmt-merge-msg' [-m <message>] [--log | --no-log] -F <file>
+'git fmt-merge-msg' [-m <message>] [--log[=<n>] | --no-log] <$GIT_DIR/FETCH_HEAD
+'git fmt-merge-msg' [-m <message>] [--log[=<n>] | --no-log] -F <file>
 
 DESCRIPTION
 -----------
@@ -24,10 +24,10 @@ automatically invoking 'git merge'.
 OPTIONS
 -------
 
---log::
+--log[=<n>]::
 	In addition to branch names, populate the log message with
-	one-line descriptions from the actual commits that are being
-	merged.
+	one-line descriptions from at most <n> actual commits that are
+	being merged. If omitted, <n> defaults to 20.
 
 --no-log::
 	Do not list one-line descriptions from the actual commits being
Documentation/merge-options.txt +3 -3
index 722d704..1083f19 100644
@@ -16,11 +16,11 @@ inspect and further tweak the merge result before committing.
 With --no-ff Generate a merge commit even if the merge
 resolved as a fast-forward.
 
---log::
+--log[=<n>]::
 --no-log::
 	In addition to branch names, populate the log message with
-	one-line descriptions from the actual commits that are being
-	merged.
+	one-line descriptions from <n> actual commits that are being
+	merged. See also linkgit:git-fmt-merge-msg[1].
 +
 With --no-log do not list one-line descriptions from the
 actual commits being merged.
builtin/fmt-merge-msg.c +14 -11
index 4ed728a..1c5da95 100644
@@ -7,21 +7,21 @@
 #include "string-list.h"
 
 static const char * const fmt_merge_msg_usage[] = {
-	"git fmt-merge-msg [-m <message>] [--log|--no-log] [--file <file>]",
+	"git fmt-merge-msg [-m <message>] [--log[=<n>]|--no-log] [--file <file>]",
 	NULL
 };
 
-static int merge_summary;
+static int shortlog_len;
 
 static int fmt_merge_msg_config(const char *key, const char *value, void *cb)
 {
 	static int found_merge_log = 0;
 	if (!strcmp("merge.log", key)) {
 		found_merge_log = 1;
-		merge_summary = git_config_bool(key, value);
+		shortlog_len = git_config_bool(key, value);
 	}
 	if (!found_merge_log && !strcmp("merge.summary", key))
-		merge_summary = git_config_bool(key, value);
+		shortlog_len = git_config_bool(key, value);
 	return 0;
 }
 
@@ -318,10 +318,12 @@ 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 },
+		{ OPTION_INTEGER, 0, "log", &shortlog_len, "n",
+		  "populate log with <n> entries from shortlog",
+		  PARSE_OPT_OPTARG, NULL, 20 },
+		{ OPTION_INTEGER, 0, "summary", &shortlog_len, "n",
+                  "alias for --log (deprecated)",
+		  PARSE_OPT_OPTARG | PARSE_OPT_HIDDEN, NULL, 20 },
 		OPT_STRING('m', "message", &message, "text",
 			"use <text> as start of message"),
 		OPT_FILENAME('F', "file", &inpath, "file to read from"),
@@ -337,7 +339,7 @@ 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) {
+	if (message && !shortlog_len) {
 		char nl = '\n';
 		write_in_full(STDOUT_FILENO, message, strlen(message));
 		write_in_full(STDOUT_FILENO, &nl, 1);
@@ -354,10 +356,11 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
 		die_errno("could not read input file");
 	if (message) {
 		strbuf_addstr(&output, message);
-		ret = fmt_merge_msg(&input, &output, 0, 20);
+		ret = fmt_merge_msg(&input, &output, 0,
+				    shortlog_len);
 	} else {
 		ret = fmt_merge_msg(&input, &output, 1,
-				    merge_summary ? 20 : 0);
+				    shortlog_len);
 	}
 	if (ret)
 		return ret;
builtin/merge.c +10 -8
index d47f48f..994b0c5 100644
@@ -42,7 +42,7 @@ static const char * const builtin_merge_usage[] = {
 	NULL
 };
 
-static int show_diffstat = 1, option_log, squash;
+static int show_diffstat = 1, shortlog_len, squash;
 static int option_commit = 1, allow_fast_forward = 1;
 static int fast_forward_only;
 static int allow_trivial = 1, have_message;
@@ -177,8 +177,9 @@ static struct option builtin_merge_options[] = {
 	OPT_BOOLEAN(0, "stat", &show_diffstat,
 		"show a diffstat at the end of the merge"),
 	OPT_BOOLEAN(0, "summary", &show_diffstat, "(synonym to --stat)"),
-	OPT_BOOLEAN(0, "log", &option_log,
-		"add list of one-line log to merge commit message"),
+	{ OPTION_INTEGER, 0, "log", &shortlog_len, "n",
+	  "populate log with <n> entries from shortlog",
+	  PARSE_OPT_OPTARG, NULL, 20 },
 	OPT_BOOLEAN(0, "squash", &squash,
 		"create a single commit instead of doing a merge"),
 	OPT_BOOLEAN(0, "commit", &option_commit,
@@ -505,7 +506,7 @@ static int git_merge_config(const char *k, const char *v, void *cb)
 	else if (!strcmp(k, "pull.octopus"))
 		return git_config_string(&pull_octopus, k, v);
 	else if (!strcmp(k, "merge.log") || !strcmp(k, "merge.summary"))
-		option_log = git_config_bool(k, v);
+		shortlog_len = git_config_bool(k, v);
 	else if (!strcmp(k, "merge.renormalize"))
 		option_renormalize = git_config_bool(k, v);
 	return git_diff_ui_config(k, v, cb);
@@ -1013,14 +1014,15 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		for (i = 0; i < argc; i++)
 			merge_name(argv[i], &merge_names);
 
-		if (have_message && option_log)
-			fmt_merge_msg(&merge_names, &merge_msg, 0, 20);
+		if (have_message && shortlog_len)
+			fmt_merge_msg(&merge_names, &merge_msg, 0,
+				      shortlog_len);
 		else if (!have_message)
 			fmt_merge_msg(&merge_names, &merge_msg, 1,
-				      option_log ? 20: 0);
+				      shortlog_len);
 
 
-		if (!(have_message && !option_log) && merge_msg.len)
+		if (!(have_message && !shortlog_len) && merge_msg.len)
 			strbuf_setlen(&merge_msg, merge_msg.len-1);
 	}
 
Signature · 1 line
1.7.2.2.409.gdbb11.dirty
Reviewed-by on v5 2/5
#6 lore raw

Re: [PATCH v5 2/5] merge: Make '--log' an integer option for number of shortlog entries

Quoted 5 lines · Ramkumar Ramachandra
 Documentation/git-fmt-merge-msg.txt |   10 +++++-----
 Documentation/merge-options.txt     |    6 +++---
 builtin/fmt-merge-msg.c             |   25 ++++++++++++++-----------
 builtin/merge.c                     |   18 ++++++++++--------
 4 files changed, 32 insertions(+), 27 deletions(-)

Is this on top of "next"? I had trouble applying it on top of the update-contrib-example-merge topic.

Documentation/git-fmt-merge-msg.txt automatically invoking 'git merge'. · line 30

Quoted 13 lines
Documentation/git-fmt-merge-msg.txt +3 -3
@@ -24,10 +24,10 @@ automatically invoking 'git merge'.
 OPTIONS
 -------
 
---log::
+--log[=<n>]::
 	In addition to branch names, populate the log message with
-	one-line descriptions from the actual commits that are being
-	merged.
+	one-line descriptions from at most <n> actual commits that are
+	being merged. If omitted, <n> defaults to 20.

The description feels a bit awkward. Maybe:

In addition to branch names, populate the log message with one-line descriptions from the actual commits that are being merged. At most <n> commits from each merge parent will be used (20 if <n> is omitted). This overrides the merge.log configuration variable.

Documentation/git-fmt-merge-msg.txt inspect and further tweak the merge result before committing. · line 23

Quoted 13 lines
Documentation/git-fmt-merge-msg.txt +4 -3
+++ b/Documentation/merge-options.txt
@@ -16,11 +16,11 @@ inspect and further tweak the merge result before committing.
 With --no-ff Generate a merge commit even if the merge
 resolved as a fast-forward.
 
---log::
+--log[=<n>]::
 --no-log::
 	In addition to branch names, populate the log message with
-	one-line descriptions from the actual commits that are being
-	merged.
+	one-line descriptions from <n> actual commits that are being
+	merged. See also linkgit:git-fmt-merge-msg[1].

Maybe s/<n>/at most <n>/.

builtin/fmt-merge-msg.c line 14

Quoted 13 lines
builtin/fmt-merge-msg.c +2 -2
@@ -7,21 +7,21 @@
 #include "string-list.h"
 
 static const char * const fmt_merge_msg_usage[] = {
-	"git fmt-merge-msg [-m <message>] [--log|--no-log] [--file <file>]",
+	"git fmt-merge-msg [-m <message>] [--log[=<n>]|--no-log] [--file <file>]",
 	NULL
 };
 
-static int merge_summary;
+static int shortlog_len;

Before: merge_summary is 1 for --log, 0 for --no-log.
After: shortlog_len is 20 for --log, 0 for --no-log, right?

builtin/fmt-merge-msg.c line 24

Quoted 11 lines
builtin/fmt-merge-msg.c +2 -2
 static int fmt_merge_msg_config(const char *key, const char *value, void *cb)
 {
 	static int found_merge_log = 0;
 	if (!strcmp("merge.log", key)) {
 		found_merge_log = 1;
-		merge_summary = git_config_bool(key, value);
+		shortlog_len = git_config_bool(key, value);
 	}
 	if (!found_merge_log && !strcmp("merge.summary", key))
-		merge_summary = git_config_bool(key, value);
+		shortlog_len = git_config_bool(key, value);

So should this say something like

	shortlog_len = git_config_bool(key, value) ?
				DEFAULT_MERGE_LOG_LEN : 0;

?

Quoted 4 lines
builtin/fmt-merge-msg.c +0 -0
@@ -318,10 +318,12 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
 	const char *inpath = NULL;
 	const char *message = NULL;
 	struct option options[] = {

builtin/fmt-merge-msg.c int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix) · line 326

Quoted 10 lines
builtin/fmt-merge-msg.c +6 -4
-		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 },
+		{ OPTION_INTEGER, 0, "log", &shortlog_len, "n",
+		  "populate log with <n> entries from shortlog",
+		  PARSE_OPT_OPTARG, NULL, 20 },
+		{ OPTION_INTEGER, 0, "summary", &shortlog_len, "n",
+                  "alias for --log (deprecated)",
+		  PARSE_OPT_OPTARG | PARSE_OPT_HIDDEN, NULL, 20 },

Whitespace damage.

Quoted 11 lines
builtin/fmt-merge-msg.c +2 -1
+++ b/builtin/merge.c
@@ -42,7 +42,7 @@ static const char * const builtin_merge_usage[] = {
 	NULL
 };
 
-static int show_diffstat = 1, option_log, squash;
+static int show_diffstat = 1, shortlog_len, squash;
 static int option_commit = 1, allow_fast_forward = 1;
 static int fast_forward_only;
 static int allow_trivial = 1, have_message;

builtin/fmt-merge-msg.c static struct option builtin_merge_options[] = { · line 181

Quoted 7 lines
builtin/fmt-merge-msg.c +2 -2
@@ -177,8 +177,9 @@ static struct option builtin_merge_options[] = {
 	OPT_BOOLEAN(0, "stat", &show_diffstat,
 		"show a diffstat at the end of the merge"),
 	OPT_BOOLEAN(0, "summary", &show_diffstat, "(synonym to --stat)"),
-	OPT_BOOLEAN(0, "log", &option_log,
-		"add list of one-line log to merge commit message"),
+	{ OPTION_INTEGER, 0, "log", &shortlog_len, "n",
+	  "populate log with <n> entries from shortlog",

The emphasis seems wrong: the important thing is still that --log uses a shortlog, not the number of entries. Maybe something like

"populate log with (at most <n>) entries from shortlog"

but that might make "git merge -h" use more than 80 columns...

builtin/fmt-merge-msg.c static int git_merge_config(const char *k, const char *v, void *cb) · line 509

Quoted 7 lines
builtin/fmt-merge-msg.c +1 -1
 	OPT_BOOLEAN(0, "commit", &option_commit,
@@ -505,7 +506,7 @@ static int git_merge_config(const char *k, const char *v, void *cb)
 	else if (!strcmp(k, "pull.octopus"))
 		return git_config_string(&pull_octopus, k, v);
 	else if (!strcmp(k, "merge.log") || !strcmp(k, "merge.summary"))
-		option_log = git_config_bool(k, v);
+		shortlog_len = git_config_bool(k, v);

As before (is this missing a " ? DEFAULT_MERGE_LOG_LEN : 0"?).

Except as noted above,

#7 lore raw

Re: [PATCH v5 2/5] merge: Make '--log' an integer option for number of shortlog entries

Hi Jonathan,

Quoted 10 lines · Jonathan Nieder
Quoted 5 lines · Ramkumar Ramachandra
 Documentation/git-fmt-merge-msg.txt |   10 +++++-----
 Documentation/merge-options.txt     |    6 +++---
 builtin/fmt-merge-msg.c             |   25 ++++++++++++++-----------
 builtin/merge.c                     |   18 ++++++++++--------
 4 files changed, 32 insertions(+), 27 deletions(-)

Is this on top of "next"? I had trouble applying it on top of the update-contrib-example-merge topic.

[...]

Due to an unfortunate mistake on my part, it's based on pu. I'll fix all the issues you pointed out and re-roll on top of rr/fmt-merge-msg later today. Thanks.

-- Ram

#8 lore raw

PATCH v5 3/5 merge: Make 'merge.log' an integer or boolean option

In reply to Ramkumar Ramachandra

Make 'merge.log' an integer or boolean option to set the number of shortlog entries to display in the merge commit. Note that it defaults to false, and that true means a default value of 20. Also update corresponding documentation.

Thanks-to: Jonathan Nieder <[email protected]>
Thanks-to: Johannes Sixt <[email protected]>

---
 Documentation/git-fmt-merge-msg.txt |    8 +++++---
 Documentation/merge-config.txt      |    8 ++++++--
 builtin/fmt-merge-msg.c             |   11 +++++------
 builtin/merge.c                     |    8 ++++++--
 4 files changed, 22 insertions(+), 13 deletions(-)
Documentation/git-fmt-merge-msg.txt +5 -3
index 14ac466..5954a53 100644
@@ -25,9 +25,11 @@ OPTIONS
 -------
 
 --log[=<n>]::
-	In addition to branch names, populate the log message with
-	one-line descriptions from at most <n> actual commits that are
-	being merged. If omitted, <n> defaults to 20.
+	Whether to include summaries of merged commits in newly
+	created merge commit messages.  Optionally, an integer can be
+	used to specify how many merged commits to summarize (at
+	maxmium) in the merge message.  Specifying "true" is
+	equivalent to specifying 20.  Defaults to false.
 
 --no-log::
 	Do not list one-line descriptions from the actual commits being
Documentation/merge-config.txt +6 -2
index b72f533..510c0ad 100644
@@ -7,8 +7,12 @@ merge.conflictstyle::
 	marker and the original text before the `=======` marker.
 
 merge.log::
-	Whether to include summaries of merged commits in newly created
-	merge commit messages. False by default.
+	Whether to include summaries of merged commits in newly
+	created merge commit messages.  Optionally, an integer can be
+	used to specify how many merged commits to summarize (at
+	maxmium) in the merge message.  Specifying "true" is
+	equivalent to specifying 20.  Defaults to false. See also
+	linkgit:git-fmt-merge-msg[1].
 
 merge.renameLimit::
 	The number of files to consider when performing rename detection
builtin/fmt-merge-msg.c +5 -6
index 1c5da95..6a2c9c8 100644
@@ -15,13 +15,12 @@ static int shortlog_len;
 
 static int fmt_merge_msg_config(const char *key, const char *value, void *cb)
 {
-	static int found_merge_log = 0;
-	if (!strcmp("merge.log", key)) {
-		found_merge_log = 1;
-		shortlog_len = git_config_bool(key, value);
+	if (!strcmp(key, "merge.log") || !strcmp(key, "merge.summary")) {
+		int is_bool;
+		shortlog_len = git_config_bool_or_int(key, value, &is_bool);
+		if (is_bool && shortlog_len)
+			shortlog_len = 20;
 	}
-	if (!found_merge_log && !strcmp("merge.summary", key))
-		shortlog_len = git_config_bool(key, value);
 	return 0;
 }
 
builtin/merge.c +6 -2
index 994b0c5..78d6c69 100644
@@ -505,8 +505,12 @@ static int git_merge_config(const char *k, const char *v, void *cb)
 		return git_config_string(&pull_twohead, k, v);
 	else if (!strcmp(k, "pull.octopus"))
 		return git_config_string(&pull_octopus, k, v);
-	else if (!strcmp(k, "merge.log") || !strcmp(k, "merge.summary"))
-		shortlog_len = git_config_bool(k, v);
+	else if (!strcmp(k, "merge.log") || !strcmp(k, "merge.summary")) {
+		int is_bool;
+		shortlog_len = git_config_bool_or_int(k, v, &is_bool);
+		if (is_bool && shortlog_len)
+			shortlog_len = 20;
+	}
 	else if (!strcmp(k, "merge.renormalize"))
 		option_renormalize = git_config_bool(k, v);
 	return git_diff_ui_config(k, v, cb);
Signature · 1 line
1.7.2.2.409.gdbb11.dirty
#9 lore raw

Re: [PATCH v5 3/5] merge: Make 'merge.log' an integer or boolean option

This makes sense, but I agree with Jonathan's reviews on 1/5 and 2/5, I'll ask you to reroll this on top of what I'll push out shortly.

As to 4/5, I think we should proceed a lot more carefully than what your patch does, just like we were extra careful when we went to v1.7.0 than when we went to v1.6.0 (see release notes to 1.6.6 for a summary, especially paying attention to the third and the fourth paragraph in "Preparing yourselves" section).

I've queued 5/5 directly on maint.

Thanks.

#10 lore raw

Re: [PATCH v5 3/5] merge: Make 'merge.log' an integer or boolean option

Hi Junio,

Quoted 2 lines · Junio C Hamano

This makes sense, but I agree with Jonathan's reviews on 1/5 and 2/5, I'll ask you to reroll this on top of what I'll push out shortly.

Thanks! I'll rebase on top of rr/fmt-merge-msg in pu and re-roll later today.

Quoted 5 lines

As to 4/5, I think we should proceed a lot more carefully than what your patch does, just like we were extra careful when we went to v1.7.0 than when we went to v1.6.0 (see release notes to 1.6.6 for a summary, especially paying attention to the third and the fourth paragraph in "Preparing yourselves" section).

Ok, I'll look at this and fix the patch accordingly.

Quoted 1 line

I've queued 5/5 directly on maint.

Right, I saw that.

-- Ram

#11 lore raw

PATCH v5 4/5 fmt-merge-msg: Remove deprecated '--summary' option

In reply to Ramkumar Ramachandra

Remove the deprecated '--summary' option that served as a syonym to the '--log' option. Also update the documentation accordingly.

---
 Documentation/git-fmt-merge-msg.txt |    9 ---------
 Documentation/merge-options.txt     |    5 -----
 builtin/fmt-merge-msg.c             |    5 +----
 builtin/merge.c                     |    2 +-
 4 files changed, 2 insertions(+), 19 deletions(-)
Documentation/git-fmt-merge-msg.txt +0 -9
index 5954a53..a0eb7e2 100644
@@ -35,11 +35,6 @@ OPTIONS
 	Do not list one-line descriptions from the actual commits being
 	merged.
 
---summary::
---no-summary::
-	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
@@ -57,10 +52,6 @@ merge.log::
 	Whether to include summaries of merged commits in newly
 	merge commit messages. False by default.
 
-merge.summary::
-	Synonym to `merge.log`; this is deprecated and will be removed in
-	the future.
-
 SEE ALSO
 --------
 linkgit:git-merge[1]
Documentation/merge-options.txt +0 -5
index 1083f19..8001005 100644
@@ -67,11 +67,6 @@ option can be used to override --squash.
 	Pass merge strategy specific option through to the merge
 	strategy.
 
---summary::
---no-summary::
-	Synonyms to --stat and --no-stat; these are deprecated and will be
-	removed in the future.
-
 ifndef::git-pull[]
 -q::
 --quiet::
builtin/fmt-merge-msg.c +1 -4
index 6a2c9c8..4255890 100644
@@ -15,7 +15,7 @@ static int shortlog_len;
 
 static int fmt_merge_msg_config(const char *key, const char *value, void *cb)
 {
-	if (!strcmp(key, "merge.log") || !strcmp(key, "merge.summary")) {
+	if (!strcmp(key, "merge.log")) {
 		int is_bool;
 		shortlog_len = git_config_bool_or_int(key, value, &is_bool);
 		if (is_bool && shortlog_len)
@@ -320,9 +320,6 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
 		{ OPTION_INTEGER, 0, "log", &shortlog_len, "n",
 		  "populate log with <n> entries from shortlog",
 		  PARSE_OPT_OPTARG, NULL, 20 },
-		{ OPTION_INTEGER, 0, "summary", &shortlog_len, "n",
-                  "alias for --log (deprecated)",
-		  PARSE_OPT_OPTARG | PARSE_OPT_HIDDEN, NULL, 20 },
 		OPT_STRING('m', "message", &message, "text",
 			"use <text> as start of message"),
 		OPT_FILENAME('F', "file", &inpath, "file to read from"),
builtin/merge.c +1 -1
index 78d6c69..9196428 100644
@@ -505,7 +505,7 @@ static int git_merge_config(const char *k, const char *v, void *cb)
 		return git_config_string(&pull_twohead, k, v);
 	else if (!strcmp(k, "pull.octopus"))
 		return git_config_string(&pull_octopus, k, v);
-	else if (!strcmp(k, "merge.log") || !strcmp(k, "merge.summary")) {
+	else if (!strcmp(k, "merge.log")) {
 		int is_bool;
 		shortlog_len = git_config_bool_or_int(k, v, &is_bool);
 		if (is_bool && shortlog_len)
Signature · 1 line
1.7.2.2.409.gdbb11.dirty
#12 lore raw

PATCH v5 5/5 parse-options: clarify PARSE_OPT_NOARG description

In reply to Ramkumar Ramachandra

From: Jonathan Nieder <[email protected]>

Here "takes no argument" means "does not take an argument". The latter phrasing might make it clearer that PARSE_OPT_NOARG does not make an option with an argument that can optionally be left off.

---
 parse-options.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
parse-options.h +1 -1
index d3b1932..f5ee3a0 100644
@@ -69,7 +69,7 @@ typedef int parse_opt_cb(const struct option *, const char *arg, int unset);
  * `flags`::
  *   mask of parse_opt_option_flags.
  *   PARSE_OPT_OPTARG: says that the argument is optional (not for BOOLEANs)
- *   PARSE_OPT_NOARG: says that this option takes no argument
+ *   PARSE_OPT_NOARG: says that this option does not take an argument
  *   PARSE_OPT_NONEG: says that this option cannot be negated
  *   PARSE_OPT_HIDDEN: this option is skipped in the default usage, and
  *                     shown only in the full usage.
Signature · 1 line
1.7.2.2.409.gdbb11.dirty