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

[PATCH] Fix "quote" misconversion for rewrite diff output.

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 22, 2007, 08:36 UTC
Message-ID
<7v4pfe8ynd.fsf@gitster.siamese.dyndns.org>

663af3422a648e87945e4d8c0cc3e13671f2bbde (Full rework of quote_c_style and write_name_quoted.) mistakenly used puts() when writing out a fixed string when it did not want to add a terminating LF.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 diff.c                  |    2 +-
 t/t4022-diff-rewrite.sh |   26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletions(-)
 create mode 100755 t/t4022-diff-rewrite.sh
diff --git a/diff.c b/diff.c
index b08d28a..6b54959 100644
--- a/diff.c
+++ b/diff.c
@@ -2716,7 +2716,7 @@ static void diff_summary(struct diff_filepair *p)
 		break;
 	default:
 		if (p->score) {
-			puts(" rewrite ");
+			fputs(" rewrite ", stdout);
 			write_name_quoted(p->two->path, stdout, ' ');
 			printf("(%d%%)\n", similarity_index(p));
 		}
diff --git a/t/t4022-diff-rewrite.sh b/t/t4022-diff-rewrite.sh
new file mode 100755
index 0000000..6de4acb
--- /dev/null
+++ b/t/t4022-diff-rewrite.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+test_description='rewrite diff'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+
+	cat ../../COPYING >test &&
+	git add test &&
+	tr 'a-zA-Z' 'n-za-mN-ZA-M' <../../COPYING >test
+
+'
+
+test_expect_success 'detect rewrite' '
+
+	actual=$(git diff-files -B --summary test) &&
+	expr "$actual" : " rewrite test ([0-9]*%)$" || {
+		echo "Eh? <<$actual>>"
+		false
+	}
+
+'
+
+test_done
+
-- 
1.5.3.6.1929.g388a
Message 1 of 1 in “Fix "quote" misconversion for rewrite diff output.”
  1. Fix "quote" misconversion for rewrite diff output.Junio C Hamano, Nov 22, 2007

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.