summaryrefslogtreecommitdiff
path: root/builtin/fmt-merge-msg.c
diff options
context:
space:
mode:
authorRamkumar Ramachandra <artagnon@gmail.com>2010-09-08 17:59:53 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-09-09 18:39:20 (GMT)
commit1876166aaab56056083e6a61de4423d130d4dcc6 (patch)
tree36aa247bd4c5ab3009ce3d8ee5837ad36ae34145 /builtin/fmt-merge-msg.c
parentfdc4408a8980392f2cc30dc125906a61edf170ec (diff)
downloadgit-1876166aaab56056083e6a61de4423d130d4dcc6.zip
git-1876166aaab56056083e6a61de4423d130d4dcc6.tar.gz
git-1876166aaab56056083e6a61de4423d130d4dcc6.tar.bz2
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> Mentored-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/fmt-merge-msg.c')
-rw-r--r--builtin/fmt-merge-msg.c30
1 files changed, 14 insertions, 16 deletions
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);