From ad2f7255b3e93dacd0982a946d30f6595dd8a805 Mon Sep 17 00:00:00 2001 From: Max Kirillov Date: Thu, 15 May 2014 01:12:45 +0300 Subject: git-show: fix 'git show -s' to not add extra terminator after merge commit When git show -s is called for merge commit it prints extra newline after any merge commit. This differs from output for commits with one parent. Fix it by more thorough checking that diff output is disabled. The code in question exists since commit 3969cf7db1. The additional newline is really needed for cases when patch is requested, test t4013-diff-various.sh contains cases which can demonstrate behavior when the condition is restricted further. Tests: Added merge commit to 'set up a bit of history' case in t7007-show.sh to cover the fix. Existing tests are updated to demonstrate the new behaviour. Earlier, the tests that used "git show -s --pretty=format:%s", even though "--pretty=format:%s" calls for item separator semantics and does not ask for the terminating newline after the last item, expected the output to end with such a newline. They were relying on the buggy behaviour. Use of "--format=%s", which is equivalent to "--pretty=tformat:%s" that asks for a terminating newline after each item, is a more realistic way to use the command. In the test 'merge log messages' the expected data is changed, because it was explicitly listing the extra newline. Also the msg.nologff and msg.nolognoff expected files are replaced by one msg.nolog, because they were diffing because of the bug, and now there should be no difference. Signed-off-by: Max Kirillov Signed-off-by: Junio C Hamano --- combine-diff.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'combine-diff.c') diff --git a/combine-diff.c b/combine-diff.c index 3b92c4488..ff6ceafe6 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -1331,7 +1331,8 @@ void diff_tree_combined(const unsigned char *sha1, if (show_log_first && i == 0) { show_log(rev); - if (rev->verbose_header && opt->output_format) + if (rev->verbose_header && opt->output_format && + opt->output_format != DIFF_FORMAT_NO_OUTPUT) printf("%s%c", diff_line_prefix(opt), opt->line_termination); } -- cgit v1.2.1