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

[PATCH 2/4] diffcore_filespec: add is_binary

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 29, 2007, 06:35 UTC
Message-ID
<11830989621033-git-send-email-gitster@pobox.com>
In-Reply-To
<7v3b0bi88r.fsf@assigned-by-dhcp.pobox.com>

diffcore-break and diffcore-rename would want to behave slightly differently depending on the binary-ness of the data, so add one bit to the filespec, as the structure is now passed down to diffcore_count_changes() function.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 diff.c     |   16 ++++++++++++++++
 diffcore.h |    1 +
 2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/diff.c b/diff.c
index 9938969..74c1198 100644
--- a/diff.c
+++ b/diff.c
@@ -3005,6 +3005,22 @@ void diffcore_std(struct diff_options *options)
 {
 	if (options->quiet)
 		return;
+
+	/*
+	 * break/rename count similarity differently depending on
+	 * the binary-ness.
+	 */
+	if ((options->break_opt != -1) || (options->detect_rename)) {
+		struct diff_queue_struct *q = &diff_queued_diff;
+		int i;
+
+		for (i = 0; i < q->nr; i++) {
+			struct diff_filepair *p = q->queue[i];
+			p->one->is_binary = file_is_binary(p->one);
+			p->two->is_binary = file_is_binary(p->two);
+		}
+	}
+
 	if (options->break_opt != -1)
 		diffcore_break(options->break_opt);
 	if (options->detect_rename)
diff --git a/diffcore.h b/diffcore.h
index 990dec5..0c8abb5 100644
--- a/diffcore.h
+++ b/diffcore.h
@@ -37,6 +37,7 @@ struct diff_filespec {
 #define DIFF_FILE_VALID(spec) (((spec)->mode) != 0)
 	unsigned should_free : 1; /* data should be free()'ed */
 	unsigned should_munmap : 1; /* data should be munmap()'ed */
+	unsigned is_binary : 1; /* data should be considered "binary" */
 };
 
 extern struct diff_filespec *alloc_filespec(const char *);
-- 
1.5.2.2.1414.g1e7d9
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 9 in “Applying patches in a directory that isn't a repository”
  1. Geoff RussellJun 29, 2007
  2. Junio C HamanoJun 29, 2007
  3. 1/4 diffcore_count_changes: pass diffcore_filespecJunio C Hamano, Jun 29, 2007
  4. 2/4 diffcore_filespec: add is_binaryJunio C Hamano, Jun 29, 2007
  5. 3/4 diffcore-delta.c: update the comment on the algorithm.Junio C Hamano, Jun 29, 2007
  6. 4/4 diffcore-delta.c: Ignore CR in CRLF for text filesJunio C Hamano, Jun 29, 2007
  7. しらいしななこJun 29, 2007
  8. Junio C HamanoJun 29, 2007
  9. Geoff RussellJun 30, 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.