summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fdc4408)
raw | patch | inline | side by side (parent: fdc4408)
author | Ramkumar Ramachandra <artagnon@gmail.com> | |
Wed, 8 Sep 2010 17:59:53 +0000 (23:29 +0530) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 9 Sep 2010 18:39:20 +0000 (11:39 -0700) |
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>
"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>
builtin.h | patch | blob | history | |
builtin/fmt-merge-msg.c | patch | blob | history | |
builtin/merge.c | patch | blob | history |
diff --git a/builtin.h b/builtin.h
index ed6ee26933430e1db4e29e62badfaf0b217935ad..09b94ea4409ed497aff68012baad897de961e80d 100644 (file)
--- a/builtin.h
+++ b/builtin.h
#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[];
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 {
index 937d5a717ba3dd71e908f59297a5085e31b48c07..42021d327e4278439f078a84c5fe73a82e0e4b22 100644 (file)
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
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;
if (merge_title)
do_fmt_merge_msg_title(out, current_branch);
- if (merge_summary) {
+ if (shortlog_len) {
struct commit *head;
struct rev_info rev;
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)
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 2207f79969975225077ff16c7c368c4652548862..b2c09848fdc2a49734307613cce6f3c48b2dd64e 100644 (file)
--- a/builtin/merge.c
+++ b/builtin/merge.c
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)