Message ID | 20240320003139.GD904136@coredump.intra.peff.net (mailing list archive) |
---|---|
State | Accepted |
Commit | 82363d967042ca2884b087b0895bbc566704388e |
Headers | show |
Series | [1/6] shortlog: stop setting pp.print_email_subject | expand |
On Wed, Mar 20, 2024, at 01:31, Jeff King wrote: > The commit pretty-printer code has an "after_subject" parameter which it > uses to insert extra headers into the email format. In show_log() we set > this by calling log_write_email_headers() if we are using an email > format, but otherwise default the variable to the rev_info.extra_headers > variable. > > Since the pretty-printer code will ignore after_subject unless we are > using an email format, this default is pointless. We can just set > after_subject directly, eliminating an extra variable. > > Signed-off-by: Jeff King <peff@peff.net> Good. I did feel like the code was kind of daisy-chaining assignments for no obvious reason. > --- > This one is enabled by the previous commits. And after this now both > callers of log_write_email_headers() directly pass in "after_subject", > which makes the next steps easy. Yep, these changes are being done in a nice progression.
diff --git a/log-tree.c b/log-tree.c index c27240a533..a50f79ec60 100644 --- a/log-tree.c +++ b/log-tree.c @@ -678,7 +678,6 @@ void show_log(struct rev_info *opt) struct log_info *log = opt->loginfo; struct commit *commit = log->commit, *parent = log->parent; int abbrev_commit = opt->abbrev_commit ? opt->abbrev : the_hash_algo->hexsz; - const char *extra_headers = opt->extra_headers; struct pretty_print_context ctx = {0}; opt->loginfo = NULL; @@ -739,7 +738,7 @@ void show_log(struct rev_info *opt) */ if (cmit_fmt_is_mail(opt->commit_format)) { - log_write_email_headers(opt, commit, &extra_headers, + log_write_email_headers(opt, commit, &ctx.after_subject, &ctx.need_8bit_cte, 1); ctx.rev = opt; } else if (opt->commit_format != CMIT_FMT_USERFORMAT) { @@ -807,7 +806,6 @@ void show_log(struct rev_info *opt) ctx.date_mode = opt->date_mode; ctx.date_mode_explicit = opt->date_mode_explicit; ctx.abbrev = opt->diffopt.abbrev; - ctx.after_subject = extra_headers; ctx.preserve_subject = opt->preserve_subject; ctx.encode_email_headers = opt->encode_email_headers; ctx.reflog_info = opt->reflog_info;
The commit pretty-printer code has an "after_subject" parameter which it uses to insert extra headers into the email format. In show_log() we set this by calling log_write_email_headers() if we are using an email format, but otherwise default the variable to the rev_info.extra_headers variable. Since the pretty-printer code will ignore after_subject unless we are using an email format, this default is pointless. We can just set after_subject directly, eliminating an extra variable. Signed-off-by: Jeff King <peff@peff.net> --- This one is enabled by the previous commits. And after this now both callers of log_write_email_headers() directly pass in "after_subject", which makes the next steps easy. log-tree.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)