From b9c7d6e4330e3dcdb3b3e5f013e5667e47555c95 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 29 Jul 2014 13:56:48 -0400 Subject: pretty: make empty userformats truly empty If the user provides an empty format with "--format=", we end up putting in extra whitespace that the user cannot prevent. This comes from two places: 1. If the format is missing a terminating newline, we add one automatically. This makes sense for --format=%h, but not for a truly empty format. 2. We add an extra newline between the pretty-printed format and a diff or diffstat. If the format is empty, there's no point in doing so if there's nothing to separate. With this patch, one can get a diff with no other cruft out of "diff-tree --format= $commit". Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- log-tree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'log-tree.c') diff --git a/log-tree.c b/log-tree.c index 0c53dc11ab..95e9b1da25 100644 --- a/log-tree.c +++ b/log-tree.c @@ -649,7 +649,7 @@ void show_log(struct rev_info *opt) graph_show_commit_msg(opt->graph, &msgbuf); else fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout); - if (opt->use_terminator) { + if (opt->use_terminator && !commit_format_is_empty(opt->commit_format)) { if (!opt->missing_newline) graph_show_padding(opt->graph); putchar(opt->diffopt.line_termination); @@ -676,7 +676,8 @@ int log_tree_diff_flush(struct rev_info *opt) show_log(opt); if ((opt->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT) && opt->verbose_header && - opt->commit_format != CMIT_FMT_ONELINE) { + opt->commit_format != CMIT_FMT_ONELINE && + !commit_format_is_empty(opt->commit_format)) { /* * When showing a verbose header (i.e. log message), * and not in --pretty=oneline format, we would want -- cgit v1.2.1