#include "log-tree.h"
#include "reflog-walk.h"
+struct decoration name_decoration = { "object names" };
+
static void show_parents(struct commit *commit, int abbrev)
{
struct commit_list *p;
}
}
+static void show_decorations(struct commit *commit)
+{
+ const char *prefix;
+ struct name_decoration *decoration;
+
+ decoration = lookup_decoration(&name_decoration, &commit->object);
+ if (!decoration)
+ return;
+ prefix = " (";
+ while (decoration) {
+ printf("%s%s", prefix, decoration->name);
+ prefix = ", ";
+ decoration = decoration->next;
+ }
+ putchar(')');
+}
+
/*
* Search for "^[-A-Za-z]+: [^@]+@" pattern. It usually matches
* Signed-off-by: and Acked-by: lines.
return seen_head && seen_name;
}
-static int append_signoff(char *buf, int buf_sz, int at, const char *signoff)
+static unsigned long append_signoff(char **buf_p, unsigned long *buf_sz_p,
+ unsigned long at, const char *signoff)
{
static const char signed_off_by[] = "Signed-off-by: ";
- int signoff_len = strlen(signoff);
+ size_t signoff_len = strlen(signoff);
int has_signoff = 0;
- char *cp = buf;
-
- /* Do we have enough space to add it? */
- if (buf_sz - at <= strlen(signed_off_by) + signoff_len + 3)
- return at;
+ char *cp;
+ char *buf;
+ unsigned long buf_sz;
+
+ buf = *buf_p;
+ buf_sz = *buf_sz_p;
+ if (buf_sz <= at + strlen(signed_off_by) + signoff_len + 3) {
+ buf_sz += strlen(signed_off_by) + signoff_len + 3;
+ buf = xrealloc(buf, buf_sz);
+ *buf_p = buf;
+ *buf_sz_p = buf_sz;
+ }
+ cp = buf;
/* First see if we already have the sign-off by the signer */
while ((cp = strstr(cp, signed_off_by))) {
return at;
}
+static unsigned int digits_in_number(unsigned int number)
+{
+ unsigned int i = 10, result = 1;
+ while (i <= number) {
+ i *= 10;
+ result++;
+ }
+ return result;
+}
+
void show_log(struct rev_info *opt, const char *sep)
{
- static char this_header[16384];
+ char *msgbuf = NULL;
+ unsigned long msgbuf_len = 0;
struct log_info *log = opt->loginfo;
struct commit *commit = log->commit, *parent = log->parent;
int abbrev = opt->diffopt.abbrev;
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
if (opt->parents)
show_parents(commit, abbrev_commit);
+ show_decorations(commit);
putchar(opt->diffopt.line_termination);
return;
}
if (*sep != '\n' && opt->commit_format == CMIT_FMT_ONELINE)
extra = "\n";
if (opt->shown_one && opt->commit_format != CMIT_FMT_ONELINE)
- putchar('\n');
+ putchar(opt->diffopt.line_termination);
opt->shown_one = 1;
/*
if (opt->total > 0) {
static char buffer[64];
snprintf(buffer, sizeof(buffer),
- "Subject: [PATCH %d/%d] ",
+ "Subject: [%s %0*d/%d] ",
+ opt->subject_prefix,
+ digits_in_number(opt->total),
opt->nr, opt->total);
subject = buffer;
- } else if (opt->total == 0)
- subject = "Subject: [PATCH] ";
- else
+ } else if (opt->total == 0 && opt->subject_prefix && *opt->subject_prefix) {
+ static char buffer[256];
+ snprintf(buffer, sizeof(buffer),
+ "Subject: [%s] ",
+ opt->subject_prefix);
+ subject = buffer;
+ } else {
subject = "Subject: ";
+ }
printf("From %s Mon Sep 17 00:00:00 2001\n", sha1);
if (opt->message_id)
snprintf(subject_buffer, sizeof(subject_buffer) - 1,
"%s"
"MIME-Version: 1.0\n"
- "Content-Type: multipart/mixed;\n"
+ "Content-Type: multipart/mixed;"
" boundary=\"%s%s\"\n"
"\n"
"This is a multi-part message in MIME "
snprintf(buffer, sizeof(buffer) - 1,
"--%s%s\n"
- "Content-Type: text/x-patch;\n"
+ "Content-Type: text/x-patch;"
" name=\"%s.diff\"\n"
"Content-Transfer-Encoding: 8bit\n"
- "Content-Disposition: inline;\n"
+ "Content-Disposition: %s;"
" filename=\"%s.diff\"\n\n",
mime_boundary_leader, opt->mime_boundary,
- sha1, sha1);
+ sha1,
+ opt->no_inline ? "attachment" : "inline",
+ sha1);
opt->diffopt.stat_sep = buffer;
}
- } else {
+ } else if (opt->commit_format != CMIT_FMT_USERFORMAT) {
fputs(diff_get_color(opt->diffopt.color_diff, DIFF_COMMIT),
stdout);
if (opt->commit_format != CMIT_FMT_ONELINE)
fputs("commit ", stdout);
- if (opt->left_right) {
- if (commit->object.flags & BOUNDARY)
- putchar('-');
- else if (commit->object.flags & SYMMETRIC_LEFT)
+ if (commit->object.flags & BOUNDARY)
+ putchar('-');
+ else if (opt->left_right) {
+ if (commit->object.flags & SYMMETRIC_LEFT)
putchar('<');
else
putchar('>');
printf(" (from %s)",
diff_unique_abbrev(parent->object.sha1,
abbrev_commit));
+ show_decorations(commit);
printf("%s",
diff_get_color(opt->diffopt.color_diff, DIFF_RESET));
putchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\n');
- if (opt->reflog_info)
+ if (opt->reflog_info) {
show_reflog_message(opt->reflog_info,
- opt->commit_format == CMIT_FMT_ONELINE);;
+ opt->commit_format == CMIT_FMT_ONELINE,
+ opt->date_mode);
+ if (opt->commit_format == CMIT_FMT_ONELINE) {
+ printf("%s", sep);
+ return;
+ }
+ }
}
/*
* And then the pretty-printed message itself
*/
- len = pretty_print_commit(opt->commit_format, commit, ~0u, this_header,
- sizeof(this_header), abbrev, subject,
- extra_headers, opt->relative_date);
+ len = pretty_print_commit(opt->commit_format, commit, ~0u,
+ &msgbuf, &msgbuf_len, abbrev, subject,
+ extra_headers, opt->date_mode);
if (opt->add_signoff)
- len = append_signoff(this_header, sizeof(this_header), len,
+ len = append_signoff(&msgbuf, &msgbuf_len, len,
opt->add_signoff);
- printf("%s%s%s", this_header, extra, sep);
+ if (opt->show_log_size)
+ printf("log size %i\n", len);
+
+ printf("%s%s%s", msgbuf, extra, sep);
+ free(msgbuf);
}
int log_tree_diff_flush(struct rev_info *opt)
opt->commit_format != CMIT_FMT_ONELINE) {
int pch = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH;
if ((pch & opt->diffopt.output_format) == pch)
- printf("---%c", opt->diffopt.line_termination);
- else
- putchar(opt->diffopt.line_termination);
+ printf("---");
+ putchar('\n');
}
}
diff_flush(&opt->diffopt);
shown = 1;
}
opt->loginfo = NULL;
+ maybe_flush_or_die(stdout, "stdout");
return shown;
}