git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Aug 22, 2010, 16:26 UTC
Message-ID
<1282494398-20542-2-git-send-email-artagnon@gmail.com>
In-Reply-To
<1282494398-20542-1-git-send-email-artagnon@gmail.com>

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.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Thanks-to: Jonathan Nieder <jrnieder@gmail.com>
---
 builtin.h               |    5 ++---
 builtin/fmt-merge-msg.c |   24 +++++++++++-------------
 builtin/merge.c         |    5 +++--
 3 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/builtin.h b/builtin.h
index 9c3d50b..1993166 100644
--- a/builtin.h
+++ b/builtin.h
@@ -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 {
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index e7e12ee..4ed728a 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -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;
diff --git a/builtin/merge.c b/builtin/merge.c
index 4e4ec89..d47f48f 100644
--- a/builtin/merge.c
+++ 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);
 
 
 		if (!(have_message && !option_log) && merge_msg.len)
-- 
1.7.2.2.409.gdbb11.dirty
Previous: Ramkumar RamachandraNext: Jonathan Nieder
Message 2 of 13 in “merge --log configurability”
  1. 0/5 merge --log configurabilityRamkumar Ramachandra, Aug 22, 2010
  2. 1/5 fmt_merge_msg: Change fmt_merge_msg API to accept shortlog_lenRamkumar Ramachandra, Aug 22, 2010
  3. Jonathan NiederAug 23, 2010
  4. Junio C HamanoAug 24, 2010
  5. merge, fmt_merge_msg --log: default value is DEFAULT_MERGE_LOG_LENJonathan Nieder, Aug 25, 2010
  6. 2/5 merge: Make '--log' an integer option for number of shortlog entriesRamkumar Ramachandra, Aug 22, 2010
  7. Jonathan NiederAug 23, 2010
  8. Ramkumar RamachandraAug 25, 2010
  9. 3/5 merge: Make 'merge.log' an integer or boolean optionRamkumar Ramachandra, Aug 22, 2010
  10. Junio C HamanoAug 24, 2010
  11. Ramkumar RamachandraAug 25, 2010
  12. 4/5 fmt-merge-msg: Remove deprecated '--summary' optionRamkumar Ramachandra, Aug 22, 2010
  13. 5/5 parse-options: clarify PARSE_OPT_NOARG descriptionRamkumar Ramachandra, Aug 22, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.