From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [WIP-PATCH 2/3] pretty: prepare notes message at a centralized place
Date: Wed, 17 Oct 2012 19:20:17 -0700 [thread overview]
Message-ID: <1350526818-354-3-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1350526818-354-1-git-send-email-gitster@pobox.com>
Instead of passing a boolean show_notes around, pass an optional
string buffer that is to be inserted after the log message proper is
shown.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
commit.h | 2 +-
log-tree.c | 15 ++++++++++++++-
pretty.c | 10 ++++------
3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/commit.h b/commit.h
index a822af8..e119788 100644
--- a/commit.h
+++ b/commit.h
@@ -86,7 +86,7 @@ struct pretty_print_context {
enum date_mode date_mode;
unsigned date_mode_explicit:1;
int need_8bit_cte;
- int show_notes;
+ struct strbuf *after_message_body;
struct reflog_walk_info *reflog_info;
const char *output_encoding;
};
diff --git a/log-tree.c b/log-tree.c
index c894930..95ff405 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -533,6 +533,7 @@ static void show_mergetag(struct rev_info *opt, struct commit *commit)
void show_log(struct rev_info *opt)
{
struct strbuf msgbuf = STRBUF_INIT;
+ struct strbuf appendbuf = STRBUF_INIT;
struct log_info *log = opt->loginfo;
struct commit *commit = log->commit, *parent = log->parent;
int abbrev_commit = opt->abbrev_commit ? opt->abbrev : 40;
@@ -540,7 +541,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 +648,18 @@ void show_log(struct rev_info *opt)
if (!commit->buffer)
return;
+ if (opt->show_notes) {
+ int flags;
+
+ if (opt->commit_format == CMIT_FMT_USERFORMAT)
+ flags = 0;
+ else
+ flags = NOTES_SHOW_HEADER | NOTES_INDENT;
+ format_display_notes(commit->object.sha1, &appendbuf,
+ get_log_output_encoding(), flags);
+ ctx.after_message_body = &appendbuf;
+ }
+
/*
* And then the pretty-printed message itself
*/
@@ -689,6 +701,7 @@ void show_log(struct rev_info *opt)
}
strbuf_release(&msgbuf);
+ strbuf_release(&appendbuf);
}
int log_tree_diff_flush(struct rev_info *opt)
diff --git a/pretty.c b/pretty.c
index c311a68..bdd991c 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1033,9 +1033,8 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
}
return 0; /* unknown %g placeholder */
case 'N':
- if (c->pretty_ctx->show_notes) {
- format_display_notes(commit->object.sha1, sb,
- get_log_output_encoding(), 0);
+ if (c->pretty_ctx->after_message_body) {
+ strbuf_addbuf(sb, c->pretty_ctx->after_message_body);
return 1;
}
return 0;
@@ -1418,9 +1417,8 @@ void pretty_print_commit(const struct pretty_print_context *pp,
if (pp->fmt == CMIT_FMT_EMAIL && sb->len <= beginning_of_body)
strbuf_addch(sb, '\n');
- if (pp->show_notes)
- format_display_notes(commit->object.sha1, sb, encoding,
- NOTES_SHOW_HEADER | NOTES_INDENT);
+ if (pp->after_message_body)
+ strbuf_addbuf(sb, pp->after_message_body);
free(reencoded);
}
--
1.8.0.rc3.112.gdb88a5e
next prev parent reply other threads:[~2012-10-18 2:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-18 2:20 [WIP-PATCH 0/3] Cleaning up "notes" in log output Junio C Hamano
2012-10-18 2:20 ` [WIP-PATCH 1/3] pretty: remove reencode_commit_message() Junio C Hamano
2012-10-18 2:20 ` Junio C Hamano [this message]
2012-10-18 2:20 ` [WIP-PATCH 3/3] pretty_print_commit(): do not append notes message Junio C Hamano
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=1350526818-354-3-git-send-email-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/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).