Subject: Re: wishlist bugreport: make limit configurable for do_fmt_merge_msg (merge.log)

From: Ramkumar Ramachandra <[email-masked]>
Date: Fri, 20 Aug 2010 12:17:44 +0530

Hi Yaroslav,

Yaroslav Halchenko writes:
> merge.log (or merge.summary) enables a really nice feature of including
> a list of commits involved in the merge.  Unfortunately it is limited to
> 20 entries and only includes total number of included commits if that is
> larger than 20.
> 
> Looking at the source code (if I got it right)
> 
> 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;
> .... no line touches limit ....
> 			shortlog(origins.items[i].string, origins.items[i].util,
> 					head, &rev, limit, out);
> 
> so, limit of 20 is hardcoded and cannot be altered via configuration.  I
> would love to have it configurable, so, if desired, be set to infinity
> (configuration wide or as a cmd line parameter for a specific merge).

You're perhpas looking for something like this? Warning: Untested.

-- 8< --
commit 86c34c682345843d9138882a85ba36faf10e0d95
Author: Ramkumar Ramachandra <[email-masked]>
Date:   Fri Aug 20 12:12:59 2010 +0530

    fmt-merge-msg: Make the number of log entries in shortlog configurable
    
    Introduce a new configuration option called merge.logLimit to limit
    the number of log entries displayed in the shortlog of a merge commit
    configurable. Set the default value to 20.

diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index a76cd4e..30782f6 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -12,6 +12,7 @@ static const char * const fmt_merge_msg_usage[] = {
 };
 
 static int merge_summary;
+static int log_limit = 20;
 
 static int fmt_merge_msg_config(const char *key, const char *value, void *cb)
 {
@@ -22,6 +23,8 @@ static int fmt_merge_msg_config(const char *key, const char *value, void *cb)
 	}
 	if (!found_merge_log && !strcmp("merge.summary", key))
 		merge_summary = git_config_bool(key, value);
+	if (!strcmp("merge.logLimit", key))
+		log_limit = git_config_int(key, value);
 	return 0;
 }
 
@@ -140,7 +143,7 @@ static void print_joined(const char *singular, const char *plural,
 }
 
 static void shortlog(const char *name, unsigned char *sha1,
-		struct commit *head, struct rev_info *rev, int limit,
+		struct commit *head, struct rev_info *rev,
 		struct strbuf *out)
 {
 	int i, count = 0;
@@ -169,7 +172,7 @@ static void shortlog(const char *name, unsigned char *sha1,
 			continue;
 
 		count++;
-		if (subjects.nr > limit)
+		if (subjects.nr > log_limit)
 			continue;
 
 		format_commit_message(commit, "%s", &sb, &ctx);
@@ -182,13 +185,13 @@ static void shortlog(const char *name, unsigned char *sha1,
 			string_list_append(&subjects, strbuf_detach(&sb, NULL));
 	}
 
-	if (count > limit)
+	if (count > log_limit)
 		strbuf_addf(out, "\n* %s: (%d commits)\n", name, count);
 	else
 		strbuf_addf(out, "\n* %s:\n", name);
 
 	for (i = 0; i < subjects.nr; i++)
-		if (i >= limit)
+		if (i >= log_limit)
 			strbuf_addf(out, "  ...\n");
 		else
 			strbuf_addf(out, "  %s\n", subjects.items[i].string);
@@ -257,7 +260,7 @@ static void do_fmt_merge_msg_title(struct strbuf *out,
 
 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;
+	int i = 0, pos = 0;
 	unsigned char head_sha1[20];
 	const char *current_branch;
 
@@ -303,7 +306,7 @@ 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, out);
 	}
 	return 0;
 }