[PATCH 2/4] diffcore_filespec: add is_binary

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Junio C Hamano
Date: Thursday, June 28, 2007 - 11:35 pm

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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Applying patches in a directory that isn't a repository, Geoff Russell, (Thu Jun 28, 11:07 pm)
Re: Applying patches in a directory that isn't a repository, Junio C Hamano, (Thu Jun 28, 11:29 pm)
[PATCH 1/4] diffcore_count_changes: pass diffcore_filespec, Junio C Hamano, (Thu Jun 28, 11:35 pm)
[PATCH 2/4] diffcore_filespec: add is_binary, Junio C Hamano, (Thu Jun 28, 11:35 pm)