git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: Ramkumar Ramachandra <artagnon@gmail.com>,
	Git Mailing List <git@vger.kernel.org>,
	Johannes Sixt <j.sixt@viscovery.net>,
	Yaroslav Halchenko <debian@onerussian.com>
Subject: Re: [PATCH v5 1/5] fmt_merge_msg: Change fmt_merge_msg API to accept shortlog_len
Date: Tue, 24 Aug 2010 10:16:18 -0700	[thread overview]
Message-ID: <7vzkwcvsm5.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20100823220031.GA1308@burratino> (Jonathan Nieder's message of "Mon\, 23 Aug 2010 17\:00\:31 -0500")

Jonathan Nieder <jrnieder@gmail.com> writes:

> The rest looks good.  So except for the commit message,
>
> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>

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

-- >8 --
From: Ramkumar Ramachandra <artagnon@gmail.com>
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.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Helped-and-Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin.h               |    7 ++++---
 builtin/fmt-merge-msg.c |   30 ++++++++++++++----------------
 builtin/merge.c         |   14 ++++++--------
 3 files changed, 24 insertions(+), 27 deletions(-)

diff --git a/builtin.h b/builtin.h
index ed6ee26..09b94ea 100644
--- a/builtin.h
+++ b/builtin.h
@@ -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 {
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index 937d5a7..42021d3 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)
@@ -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);
diff --git a/builtin/merge.c b/builtin/merge.c
index 2207f79..b2c0984 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -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)
-- 
1.7.2.2.426.g2251a

  reply	other threads:[~2010-08-24 17:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-22 16:26 [PATCH v5 0/5] merge --log configurability Ramkumar Ramachandra
2010-08-22 16:26 ` [PATCH v5 1/5] fmt_merge_msg: Change fmt_merge_msg API to accept shortlog_len Ramkumar Ramachandra
2010-08-23 22:00   ` Jonathan Nieder
2010-08-24 17:16     ` Junio C Hamano [this message]
2010-08-25  2:44       ` [PATCH rr/fmt-merge-msg] merge, fmt_merge_msg --log: default value is DEFAULT_MERGE_LOG_LEN Jonathan Nieder
2010-08-22 16:26 ` [PATCH v5 2/5] merge: Make '--log' an integer option for number of shortlog entries Ramkumar Ramachandra
2010-08-23 22:25   ` Jonathan Nieder
2010-08-25  4:50     ` Ramkumar Ramachandra
2010-08-22 16:26 ` [PATCH v5 3/5] merge: Make 'merge.log' an integer or boolean option Ramkumar Ramachandra
2010-08-24 19:01   ` Junio C Hamano
2010-08-25  3:52     ` Ramkumar Ramachandra
2010-08-22 16:26 ` [PATCH v5 4/5] fmt-merge-msg: Remove deprecated '--summary' option Ramkumar Ramachandra
2010-08-22 16:26 ` [PATCH v5 5/5] parse-options: clarify PARSE_OPT_NOARG description Ramkumar Ramachandra

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vzkwcvsm5.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=artagnon@gmail.com \
    --cc=debian@onerussian.com \
    --cc=git@vger.kernel.org \
    --cc=j.sixt@viscovery.net \
    --cc=jrnieder@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).