* [WIP-PATCH 0/3] Cleaning up "notes" in log output
@ 2012-10-18 2:20 Junio C Hamano
2012-10-18 2:20 ` [WIP-PATCH 1/3] pretty: remove reencode_commit_message() Junio C Hamano
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Junio C Hamano @ 2012-10-18 2:20 UTC (permalink / raw)
To: git
This is only the preparatory step.
The obvious next one that follows will swap the "add-sign-off" logic
and appending of notes, so that sign-off will come before the notes.
And then, we will insert "---" before we add notes, leave a bit in
the rev_info for the later step in the codepath to tell it that it
does not have to add another "---", and tweak the existing codepath
that adds "---" to refrain from doing so.
Junio C Hamano (3):
pretty: remove reencode_commit_message()
pretty: prepare notes message at a centralized place
pretty_print_commit(): do not append notes message
builtin/blame.c | 5 +++--
commit.h | 4 +---
log-tree.c | 17 ++++++++++++++++-
pretty.c | 22 ++++------------------
4 files changed, 24 insertions(+), 24 deletions(-)
--
1.8.0.rc3.112.gdb88a5e
^ permalink raw reply [flat|nested] 4+ messages in thread
* [WIP-PATCH 1/3] pretty: remove reencode_commit_message()
2012-10-18 2:20 [WIP-PATCH 0/3] Cleaning up "notes" in log output Junio C Hamano
@ 2012-10-18 2:20 ` Junio C Hamano
2012-10-18 2:20 ` [WIP-PATCH 2/3] pretty: prepare notes message at a centralized place Junio C Hamano
2012-10-18 2:20 ` [WIP-PATCH 3/3] pretty_print_commit(): do not append notes message Junio C Hamano
2 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2012-10-18 2:20 UTC (permalink / raw)
To: git
This function has only two callsites, and is a thin wrapper whose
usefulness is dubious. When the caller needs to learn the log
output encoding, it should be able to do so by directly calling
get_log_output_encoding() and calling the underlying
logmsg_reencode() with it.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/blame.c | 5 +++--
commit.h | 2 --
pretty.c | 13 ++-----------
3 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/builtin/blame.c b/builtin/blame.c
index c27ef21..cfae569 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -1425,7 +1425,7 @@ static void get_commit_info(struct commit *commit,
int detailed)
{
int len;
- const char *subject;
+ const char *subject, *encoding;
char *reencoded, *message;
static char author_name[1024];
static char author_mail[1024];
@@ -1446,7 +1446,8 @@ static void get_commit_info(struct commit *commit,
die("Cannot read commit %s",
sha1_to_hex(commit->object.sha1));
}
- reencoded = reencode_commit_message(commit, NULL);
+ encoding = get_log_output_encoding();
+ reencoded = logmsg_reencode(commit, encoding);
message = reencoded ? reencoded : commit->buffer;
ret->author = author_name;
ret->author_mail = author_mail;
diff --git a/commit.h b/commit.h
index 9f21313..a822af8 100644
--- a/commit.h
+++ b/commit.h
@@ -99,8 +99,6 @@ extern int has_non_ascii(const char *text);
struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
extern char *logmsg_reencode(const struct commit *commit,
const char *output_encoding);
-extern char *reencode_commit_message(const struct commit *commit,
- const char **encoding_p);
extern void get_commit_format(const char *arg, struct rev_info *);
extern const char *format_subject(struct strbuf *sb, const char *msg,
const char *line_separator);
diff --git a/pretty.c b/pretty.c
index 8b1ea9f..c311a68 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1341,16 +1341,6 @@ void pp_remainder(const struct pretty_print_context *pp,
}
}
-char *reencode_commit_message(const struct commit *commit, const char **encoding_p)
-{
- const char *encoding;
-
- encoding = get_log_output_encoding();
- if (encoding_p)
- *encoding_p = encoding;
- return logmsg_reencode(commit, encoding);
-}
-
void pretty_print_commit(const struct pretty_print_context *pp,
const struct commit *commit,
struct strbuf *sb)
@@ -1367,7 +1357,8 @@ void pretty_print_commit(const struct pretty_print_context *pp,
return;
}
- reencoded = reencode_commit_message(commit, &encoding);
+ encoding = get_log_output_encoding();
+ reencoded = logmsg_reencode(commit, encoding);
if (reencoded) {
msg = reencoded;
}
--
1.8.0.rc3.112.gdb88a5e
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [WIP-PATCH 2/3] pretty: prepare notes message at a centralized place
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
2012-10-18 2:20 ` [WIP-PATCH 3/3] pretty_print_commit(): do not append notes message Junio C Hamano
2 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2012-10-18 2:20 UTC (permalink / raw)
To: git
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [WIP-PATCH 3/3] pretty_print_commit(): do not append notes message
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 ` [WIP-PATCH 2/3] pretty: prepare notes message at a centralized place Junio C Hamano
@ 2012-10-18 2:20 ` Junio C Hamano
2 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2012-10-18 2:20 UTC (permalink / raw)
To: git
The only case pretty_print_commit() appends notes message to the log
message taken from the commit is when show_log() calls it with the
after_message_body field set and the output format is not the
userformat. No other users of this function sets this field in the
pretty_print_context, as can be seen in the previous step.
Hoist the code to append the notes message to the caller.
Up to this point, no functionality change is intended.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
log-tree.c | 2 ++
pretty.c | 3 ---
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/log-tree.c b/log-tree.c
index 95ff405..6e141f0 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -673,6 +673,8 @@ void show_log(struct rev_info *opt)
ctx.reflog_info = opt->reflog_info;
ctx.fmt = opt->commit_format;
pretty_print_commit(&ctx, commit, &msgbuf);
+ if ((ctx.fmt != CMIT_FMT_USERFORMAT) && ctx.after_message_body)
+ strbuf_addbuf(&msgbuf, ctx.after_message_body);
if (opt->add_signoff)
append_signoff(&msgbuf, opt->add_signoff);
diff --git a/pretty.c b/pretty.c
index bdd991c..ad27325 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1417,9 +1417,6 @@ 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->after_message_body)
- strbuf_addbuf(sb, pp->after_message_body);
-
free(reencoded);
}
--
1.8.0.rc3.112.gdb88a5e
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-10-18 2:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [WIP-PATCH 2/3] pretty: prepare notes message at a centralized place Junio C Hamano
2012-10-18 2:20 ` [WIP-PATCH 3/3] pretty_print_commit(): do not append notes message Junio C Hamano
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).