Git fork

diff: correct newline in summary for renamed files

In 146fdb0dfe (diff.c: emit_diff_symbol learns about DIFF_SYMBOL_SUMMARY,
2017-06-29), the conversion from direct printing to the symbol emission
dropped the new line character for renamed, copied and rewritten files.

Add the emission of a newline, add a test for this case.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Stefan Beller and committed by
Junio C Hamano
58aaced4 61e89eaa

+35
+1
diff.c
··· 5251 5251 strbuf_addch(&sb, ' '); 5252 5252 quote_c_style(p->two->path, &sb, NULL, 0); 5253 5253 } 5254 + strbuf_addch(&sb, '\n'); 5254 5255 emit_diff_symbol(opt, DIFF_SYMBOL_SUMMARY, 5255 5256 sb.buf, sb.len, 0); 5256 5257 strbuf_release(&sb);
+12
t/t4013-diff-various.sh
··· 90 90 git commit -m "Rearranged lines in dir/sub" && 91 91 git checkout master && 92 92 93 + GIT_AUTHOR_DATE="2006-06-26 00:06:00 +0000" && 94 + GIT_COMMITTER_DATE="2006-06-26 00:06:00 +0000" && 95 + export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && 96 + git checkout -b mode initial && 97 + git update-index --chmod=+x file0 && 98 + git commit -m "update mode" && 99 + git checkout -f master && 100 + 93 101 git config diff.renames false && 94 102 95 103 git show-branch ··· 191 199 diff-tree --pretty side 192 200 diff-tree --pretty -p side 193 201 diff-tree --pretty --patch-with-stat side 202 + 203 + diff-tree initial mode 204 + diff-tree --stat initial mode 205 + diff-tree --summary initial mode 194 206 195 207 diff-tree master 196 208 diff-tree -p master
+4
t/t4013/diff.diff-tree_--stat_initial_mode
··· 1 + $ git diff-tree --stat initial mode 2 + file0 | 0 3 + 1 file changed, 0 insertions(+), 0 deletions(-) 4 + $
+3
t/t4013/diff.diff-tree_--summary_initial_mode
··· 1 + $ git diff-tree --summary initial mode 2 + mode change 100644 => 100755 file0 3 + $
+3
t/t4013/diff.diff-tree_initial_mode
··· 1 + $ git diff-tree initial mode 2 + :100644 100755 01e79c32a8c99c557f0757da7cb6d65b3414466d 01e79c32a8c99c557f0757da7cb6d65b3414466d M file0 3 + $
+6
t/t4013/diff.log_--decorate=full_--all
··· 1 1 $ git log --decorate=full --all 2 + commit b7e0bc69303b488b47deca799a7d723971dfa6cd (refs/heads/mode) 3 + Author: A U Thor <author@example.com> 4 + Date: Mon Jun 26 00:06:00 2006 +0000 5 + 6 + update mode 7 + 2 8 commit cd4e72fd96faed3f0ba949dc42967430374e2290 (refs/heads/rearrange) 3 9 Author: A U Thor <author@example.com> 4 10 Date: Mon Jun 26 00:06:00 2006 +0000
+6
t/t4013/diff.log_--decorate_--all
··· 1 1 $ git log --decorate --all 2 + commit b7e0bc69303b488b47deca799a7d723971dfa6cd (mode) 3 + Author: A U Thor <author@example.com> 4 + Date: Mon Jun 26 00:06:00 2006 +0000 5 + 6 + update mode 7 + 2 8 commit cd4e72fd96faed3f0ba949dc42967430374e2290 (rearrange) 3 9 Author: A U Thor <author@example.com> 4 10 Date: Mon Jun 26 00:06:00 2006 +0000