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>
Stefan Beller committed
Sep 27, 2017 at 15:51 UTC
58aaced4442a6daae1c82318f3f9259001714505
7 files changed
+35
diff.c
+1
@@ -5251,6 +5251,7 @@ static void show_mode_change(struct diff_options *opt, struct diff_filepair *p,
5251
strbuf_addch(&sb, ' ');
5252
quote_c_style(p->two->path, &sb, NULL, 0);
5253
}
5254
+ strbuf_addch(&sb, '\n');
5255
emit_diff_symbol(opt, DIFF_SYMBOL_SUMMARY,
5256
sb.buf, sb.len, 0);
5257
strbuf_release(&sb);
t/t4013-diff-various.sh
+12
@@ -90,6 +90,14 @@ test_expect_success setup '
90
git commit -m "Rearranged lines in dir/sub" &&
91
git checkout master &&
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
+
101
git config diff.renames false &&
102
103
git show-branch
@@ -192,6 +200,10 @@ diff-tree --pretty side
200
diff-tree --pretty -p side
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
206
+
207
diff-tree master
208
diff-tree -p master
209
diff-tree -p -m master
t/t4013/diff.diff-tree_--stat_initial_mode
new
+4
@@ -0,0 +1,4 @@
1
+$ git diff-tree --stat initial mode
2
+ file0 | 0
3
+ 1 file changed, 0 insertions(+), 0 deletions(-)
4
+$
t/t4013/diff.diff-tree_--summary_initial_mode
new
+3
@@ -0,0 +1,3 @@
1
+$ git diff-tree --summary initial mode
2
+ mode change 100644 => 100755 file0
3
+$
t/t4013/diff.diff-tree_initial_mode
new
+3
@@ -0,0 +1,3 @@
1
+$ git diff-tree initial mode
2
+:100644 100755 01e79c32a8c99c557f0757da7cb6d65b3414466d 01e79c32a8c99c557f0757da7cb6d65b3414466d M file0
3
+$
t/t4013/diff.log_--decorate=full_--all
+6
@@ -1,4 +1,10 @@
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
+
8
commit cd4e72fd96faed3f0ba949dc42967430374e2290 (refs/heads/rearrange)
9
Author: A U Thor <author@example.com>
10
Date: Mon Jun 26 00:06:00 2006 +0000
t/t4013/diff.log_--decorate_--all
+6
@@ -1,4 +1,10 @@
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
+
8
commit cd4e72fd96faed3f0ba949dc42967430374e2290 (rearrange)
9
Author: A U Thor <author@example.com>
10
Date: Mon Jun 26 00:06:00 2006 +0000