git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] diff: correct newline in summary for renamed files

From
Stefan Beller <sbeller@google.com>
Date
Sep 27, 2017, 21:58 UTC
Message-ID
<20170927215852.20163-1-sbeller@google.com>
In-Reply-To
<CAGZ79kbCgTNaunfneWHP3xkLeXwW72CZZWs7Sv8A7QL_UYE_HQ@mail.gmail.com>
From: Linus Torvalds <torvalds@linux-foundation.org>

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.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 Linus, I assumed your sign off for the original patch. Thanks for spotting.
 
 Adding the mode change to t4016 seems like the easiest way to test it.
 
 Thanks,
 Stefan
  
 diff.c                | 1 +
 t/t4016-diff-quote.sh | 2 ++
 2 files changed, 3 insertions(+)
diff --git a/diff.c b/diff.c
index 3c6a3e0faa..653bb2e72e 100644
--- a/diff.c
+++ b/diff.c
@@ -5272,6 +5272,7 @@ static void show_mode_change(struct diff_options *opt, struct diff_filepair *p,
 			strbuf_addch(&sb, ' ');
 			quote_c_style(p->two->path, &sb, NULL, 0);
 		}
+		strbuf_addch(&sb, '\n');
 		emit_diff_symbol(opt, DIFF_SYMBOL_SUMMARY,
 				 sb.buf, sb.len, 0);
 		strbuf_release(&sb);
diff --git a/t/t4016-diff-quote.sh b/t/t4016-diff-quote.sh
index 9c48e5c2c9..514056dd10 100755
--- a/t/t4016-diff-quote.sh
+++ b/t/t4016-diff-quote.sh
@@ -30,6 +30,7 @@ test_expect_success setup '
 	git add . &&
 	git commit -m initial &&
 	git mv "$P0.0" "R$P0.0" &&
+	chmod a+x "R$P0.0" &&
 	git mv "$P0.1" "R$P1.0" &&
 	git mv "$P0.2" "R$P2.0" &&
 	git mv "$P0.3" "R$P3.0" &&
@@ -47,6 +48,7 @@ cat >expect <<\EOF
  rename pathname.2 => Rpathname with SP.0 (100%)
  rename "pathname\twith HT.2" => Rpathname with SP.1 (100%)
  rename pathname.0 => Rpathname.0 (100%)
+ mode change 100644 => 100755
  rename "pathname\twith HT.0" => Rpathname.1 (100%)
 EOF
 '
-- 
2.14.0.rc0.3.g6c2e499285
Previous: Stefan BellerNext: Linus Torvalds
Message 5 of 19 in “diffstat summary mode change bug”
  1. Linus TorvaldsSep 27, 2017
  2. Stefan BellerSep 27, 2017
  3. Linus TorvaldsSep 27, 2017
  4. Stefan BellerSep 27, 2017
  5. diff: correct newline in summary for renamed filesStefan Beller, Sep 27, 2017
  6. Linus TorvaldsSep 27, 2017
  7. Jeff KingSep 27, 2017
  8. Jeff KingSep 27, 2017
  9. Stefan BellerSep 27, 2017
  10. Jeff KingSep 27, 2017
  11. diff: correct newline in summary for renamed filesStefan Beller, Sep 27, 2017
  12. Jonathan NiederSep 27, 2017
  13. Ramsay JonesSep 27, 2017
  14. Stefan BellerSep 27, 2017
  15. Jeff KingSep 28, 2017
  16. Junio C HamanoSep 28, 2017
  17. Jeff KingSep 28, 2017
  18. Stefan BellerSep 27, 2017
  19. Junio C HamanoSep 28, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.