Code

Clean up "git log" format with DIFF_FORMAT_NO_OUTPUT
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 9 Oct 2007 16:35:22 +0000 (09:35 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Tue, 16 Oct 2007 00:24:27 +0000 (20:24 -0400)
This fixes an unnecessary empty line that we add to the log message when
we generate diffs, but don't actually end up printing any due to having
DIFF_FORMAT_NO_OUTPUT set.

This can happen with pickaxe or with rename following. The reason is that
we normally add an empty line between the commit and the diff, but we do
that even for the case where we've then suppressed the actual printing of
the diff.

This also updates a couple of tests that assumed the extraneous empty
line would exist at the end of output.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
log-tree.c
t/t3900-i18n-commit.sh
t/t4013/diff.log_-SF_master

index a6423718e76be34e62bc76dcf3c93b32e38aa152..b509c0c7ec239d4f426807406d94c34feeecf009 100644 (file)
@@ -321,7 +321,8 @@ int log_tree_diff_flush(struct rev_info *opt)
                 * output for readability.
                 */
                show_log(opt, opt->diffopt.msg_sep);
-               if (opt->verbose_header &&
+               if ((opt->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT) &&
+                   opt->verbose_header &&
                    opt->commit_format != CMIT_FMT_ONELINE) {
                        int pch = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH;
                        if ((pch & opt->diffopt.output_format) == pch)
index fcbabe8ec32d61888e6cb28d393381066d1b0f3c..94b1c24b0a3629a6b06466186006a526bb9b4d9d 100755 (executable)
@@ -8,7 +8,7 @@ test_description='commit and log output encodings'
 . ./test-lib.sh
 
 compare_with () {
-       git show -s $1 | sed -e '1,/^$/d' -e 's/^    //' -e '$d' >current &&
+       git show -s $1 | sed -e '1,/^$/d' -e 's/^    //' >current &&
        git diff current "$2"
 }
 
index 6162ed2018cbf464790a2c5322422e5cce396d5d..c1599f2f520090b0717d951a69ade5a9960f8038 100644 (file)
@@ -4,5 +4,4 @@ Author: A U Thor <author@example.com>
 Date:   Mon Jun 26 00:02:00 2006 +0000
 
     Third
-
 $