Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'log-tree.c')
-rw-r--r--log-tree.c132
1 files changed, 88 insertions, 44 deletions
diff --git a/log-tree.c b/log-tree.c
index c894930c18..3d88823871 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -299,26 +299,34 @@ static unsigned int digits_in_number(unsigned int number)
return result;
}
-void get_patch_filename(struct commit *commit, const char *subject, int nr,
- const char *suffix, struct strbuf *buf)
+void fmt_output_subject(struct strbuf *filename,
+ const char *subject,
+ struct rev_info *info)
{
- int suffix_len = strlen(suffix) + 1;
- int start_len = buf->len;
-
- strbuf_addf(buf, commit || subject ? "%04d-" : "%d", nr);
- if (commit || subject) {
- int max_len = start_len + FORMAT_PATCH_NAME_MAX - suffix_len;
- struct pretty_print_context ctx = {0};
-
- if (subject)
- strbuf_addstr(buf, subject);
- else if (commit)
- format_commit_message(commit, "%f", buf, &ctx);
-
- if (max_len < buf->len)
- strbuf_setlen(buf, max_len);
- strbuf_addstr(buf, suffix);
- }
+ const char *suffix = info->patch_suffix;
+ int nr = info->nr;
+ int start_len = filename->len;
+ int max_len = start_len + FORMAT_PATCH_NAME_MAX - (strlen(suffix) + 1);
+
+ if (0 < info->reroll_count)
+ strbuf_addf(filename, "v%d-", info->reroll_count);
+ strbuf_addf(filename, "%04d-%s", nr, subject);
+
+ if (max_len < filename->len)
+ strbuf_setlen(filename, max_len);
+ strbuf_addstr(filename, suffix);
+}
+
+void fmt_output_commit(struct strbuf *filename,
+ struct commit *commit,
+ struct rev_info *info)
+{
+ struct pretty_print_context ctx = {0};
+ struct strbuf subject = STRBUF_INIT;
+
+ format_commit_message(commit, "%f", &subject, &ctx);
+ fmt_output_subject(filename, subject.buf, info);
+ strbuf_release(&subject);
}
void log_write_email_headers(struct rev_info *opt, struct commit *commit,
@@ -387,8 +395,10 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
mime_boundary_leader, opt->mime_boundary);
extra_headers = subject_buffer;
- get_patch_filename(opt->numbered_files ? NULL : commit, NULL,
- opt->nr, opt->patch_suffix, &filename);
+ if (opt->numbered_files)
+ strbuf_addf(&filename, "%d", opt->nr);
+ else
+ fmt_output_commit(&filename, commit, opt);
snprintf(buffer, sizeof(buffer) - 1,
"\n--%s%s\n"
"Content-Type: text/x-patch;"
@@ -434,7 +444,7 @@ static void show_signature(struct rev_info *opt, struct commit *commit)
status = verify_signed_buffer(payload.buf, payload.len,
signature.buf, signature.len,
- &gpg_output);
+ &gpg_output, NULL);
if (status && !gpg_output.len)
strbuf_addstr(&gpg_output, "No signature\n");
@@ -498,20 +508,17 @@ static void show_one_mergetag(struct rev_info *opt,
gpg_message_offset = verify_message.len;
payload_size = parse_signature(extra->value, extra->len);
- if ((extra->len <= payload_size) ||
- (verify_signed_buffer(extra->value, payload_size,
- extra->value + payload_size,
- extra->len - payload_size,
- &verify_message) &&
- verify_message.len <= gpg_message_offset)) {
- strbuf_addstr(&verify_message, "No signature\n");
- status = -1;
- }
- else if (strstr(verify_message.buf + gpg_message_offset,
- ": Good signature from "))
- status = 0;
- else
- status = -1;
+ status = -1;
+ if (extra->len > payload_size)
+ if (verify_signed_buffer(extra->value, payload_size,
+ extra->value + payload_size,
+ extra->len - payload_size,
+ &verify_message, NULL)) {
+ if (verify_message.len <= gpg_message_offset)
+ strbuf_addstr(&verify_message, "No signature\n");
+ else
+ status = 0;
+ }
show_sig_lines(opt, status, verify_message.buf);
strbuf_release(&verify_message);
@@ -540,7 +547,6 @@ void show_log(struct rev_info *opt)
struct pretty_print_context ctx = {0};
opt->loginfo = NULL;
- ctx.show_notes = opt->show_notes;
if (!opt->verbose_header) {
graph_show_commit(opt->graph);
@@ -648,6 +654,18 @@ void show_log(struct rev_info *opt)
if (!commit->buffer)
return;
+ if (opt->show_notes) {
+ int raw;
+ struct strbuf notebuf = STRBUF_INIT;
+
+ raw = (opt->commit_format == CMIT_FMT_USERFORMAT);
+ format_display_notes(commit->object.sha1, &notebuf,
+ get_log_output_encoding(), raw);
+ ctx.notes_message = notebuf.len
+ ? strbuf_detach(&notebuf, NULL)
+ : xcalloc(1, 1);
+ }
+
/*
* And then the pretty-printed message itself
*/
@@ -660,10 +678,22 @@ void show_log(struct rev_info *opt)
ctx.preserve_subject = opt->preserve_subject;
ctx.reflog_info = opt->reflog_info;
ctx.fmt = opt->commit_format;
+ ctx.mailmap = opt->mailmap;
+ ctx.color = opt->diffopt.use_color;
pretty_print_commit(&ctx, commit, &msgbuf);
if (opt->add_signoff)
append_signoff(&msgbuf, opt->add_signoff);
+
+ if ((ctx.fmt != CMIT_FMT_USERFORMAT) &&
+ ctx.notes_message && *ctx.notes_message) {
+ if (ctx.fmt == CMIT_FMT_EMAIL) {
+ strbuf_addstr(&msgbuf, "---\n");
+ opt->shown_dashes = 1;
+ }
+ strbuf_addstr(&msgbuf, ctx.notes_message);
+ }
+
if (opt->show_log_size) {
printf("log size %i\n", (int)msgbuf.len);
graph_show_oneline(opt->graph);
@@ -689,10 +719,12 @@ void show_log(struct rev_info *opt)
}
strbuf_release(&msgbuf);
+ free(ctx.notes_message);
}
int log_tree_diff_flush(struct rev_info *opt)
{
+ opt->shown_dashes = 0;
diffcore_std(&opt->diffopt);
if (diff_queue_is_empty()) {
@@ -704,15 +736,16 @@ int log_tree_diff_flush(struct rev_info *opt)
}
if (opt->loginfo && !opt->no_commit_id) {
- /* When showing a verbose header (i.e. log message),
- * and not in --pretty=oneline format, we would want
- * an extra newline between the end of log and the
- * output for readability.
- */
show_log(opt);
if ((opt->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT) &&
opt->verbose_header &&
opt->commit_format != CMIT_FMT_ONELINE) {
+ /*
+ * When showing a verbose header (i.e. log message),
+ * and not in --pretty=oneline format, we would want
+ * an extra newline between the end of log and the
+ * diff/diffstat output for readability.
+ */
int pch = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH;
if (opt->diffopt.output_prefix) {
struct strbuf *msg = NULL;
@@ -720,9 +753,20 @@ int log_tree_diff_flush(struct rev_info *opt)
opt->diffopt.output_prefix_data);
fwrite(msg->buf, msg->len, 1, stdout);
}
- if ((pch & opt->diffopt.output_format) == pch) {
+
+ /*
+ * We may have shown three-dashes line early
+ * between notes and the log message, in which
+ * case we only want a blank line after the
+ * notes without (an extra) three-dashes line.
+ * Otherwise, we show the three-dashes line if
+ * we are showing the patch with diffstat, but
+ * in that case, there is no extra blank line
+ * after the three-dashes line.
+ */
+ if (!opt->shown_dashes &&
+ (pch & opt->diffopt.output_format) == pch)
printf("---");
- }
putchar('\n');
}
}