git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Make attributes "-diff" and "diff" work as advertized
Date: Sun, 8 Jul 2007 01:59:20 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0707080153220.4093@racer.site> (raw)
In-Reply-To: <7vy7hr69ky.fsf@assigned-by-dhcp.cox.net>

Hi,

well, it was a quick fix. I had more on my wishlist for today, and wanted 
to be done with it quickly. The proper fix would be something like this, I 
guess (which should not be applied without the changes to t4020, of 
course):

 diff.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/diff.c b/diff.c
index 04e7e91..e47921f 100644
--- a/diff.c
+++ b/diff.c
@@ -1113,13 +1113,13 @@ static void setup_diff_attr_check(struct git_attr_check *check)
 
 static void diff_filespec_check_attr(struct diff_filespec *one)
 {
+	int is_binary = -1;
 	struct git_attr_check attr_diff_check[2];
 
 	if (one->checked_attr)
 		return;
 
 	setup_diff_attr_check(attr_diff_check);
-	one->is_binary = 0;
 	one->hunk_header_ident = NULL;
 
 	if (!git_checkattr(one->path, ARRAY_SIZE(attr_diff_check), attr_diff_check)) {
@@ -1128,9 +1128,9 @@ static void diff_filespec_check_attr(struct diff_filespec *one)
 		/* binaryness */
 		value = attr_diff_check[0].value;
 		if (ATTR_TRUE(value))
-			;
+			is_binary = 0;
 		else if (ATTR_FALSE(value))
-			one->is_binary = 1;
+			is_binary = 1;
 
 		/* hunk header ident */
 		value = attr_diff_check[1].value;
@@ -1140,11 +1140,15 @@ static void diff_filespec_check_attr(struct diff_filespec *one)
 			one->hunk_header_ident = value;
 	}
 
-	if (!one->data && DIFF_FILE_VALID(one))
-		diff_populate_filespec(one, 0);
+	if (is_binary < 0) {
+		if (!one->data && DIFF_FILE_VALID(one))
+			diff_populate_filespec(one, 0);
 
-	if (one->data)
-		one->is_binary = buffer_is_binary(one->data, one->size);
+		if (one->data)
+			one->is_binary =
+				buffer_is_binary(one->data, one->size);
+	} else
+		one->is_binary = is_binary;
 
 }
 

      reply	other threads:[~2007-07-08  1:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-07 16:53 [PATCH] Make attributes "-diff" and "diff" work as advertized Johannes Schindelin
2007-07-08  0:08 ` Junio C Hamano
2007-07-08  0:59   ` Johannes Schindelin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0707080153220.4093@racer.site \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).