git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Henrik Grubbström (Grubba)" <grubba@grubba.org>
To: git@vger.kernel.org
Cc: "Henrik Grubbström  " <grubba@grubba.org>
Subject: [PATCH RFC 5/5] cache: Use ce_norm_sha1().
Date: Fri, 16 Apr 2010 18:10:02 +0200	[thread overview]
Message-ID: <c68d98b384086925da0194e560ae01d83a29f80c.1271432034.git.grubba@grubba.org> (raw)
In-Reply-To: <cover.1271432034.git.grubba@grubba.org>
In-Reply-To: <cover.1271432034.git.grubba@grubba.org>

When the conversion filter for a file is changed, the file may get
listed as modified even though the user has not made any changes to it.
This patch makes the index ignore such changes. It also makes git-diff
compare with the normalized content rather than the original content.

Signed-off-by: Henrik Grubbström <grubba@grubba.org>
---
 diff-lib.c   |    9 ++++++---
 read-cache.c |    2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/diff-lib.c b/diff-lib.c
index c9f6e05..ae6118d 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -95,6 +95,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
 		struct cache_entry *ce = active_cache[i];
 		int changed;
 		unsigned dirty_submodule = 0;
+		const unsigned char *norm_sha1;
 
 		if (DIFF_OPT_TST(&revs->diffopt, QUICK) &&
 			DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES))
@@ -147,7 +148,8 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
 				if (2 <= stage) {
 					int mode = nce->ce_mode;
 					num_compare_stages++;
-					hashcpy(dpath->parent[stage-2].sha1, nce->sha1);
+					hashcpy(dpath->parent[stage-2].sha1,
+						ce_norm_sha1(nce));
 					dpath->parent[stage-2].mode = ce_mode_from_stat(nce, mode);
 					dpath->parent[stage-2].status =
 						DIFF_STATUS_MODIFIED;
@@ -195,7 +197,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
 			if (silent_on_removed)
 				continue;
 			diff_addremove(&revs->diffopt, '-', ce->ce_mode,
-				       ce->sha1, ce->name, 0);
+				       ce_norm_sha1(ce), ce->name, 0);
 			continue;
 		}
 		changed = match_stat_with_submodule(&revs->diffopt, ce, &st,
@@ -207,8 +209,9 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
 		}
 		oldmode = ce->ce_mode;
 		newmode = ce_mode_from_stat(ce, st.st_mode);
+		norm_sha1 = ce_norm_sha1(ce);
 		diff_change(&revs->diffopt, oldmode, newmode,
-			    ce->sha1, (changed ? null_sha1 : ce->sha1),
+			    norm_sha1, (changed ? null_sha1 : norm_sha1),
 			    ce->name, 0, dirty_submodule);
 
 	}
diff --git a/read-cache.c b/read-cache.c
index 002160e..b631de9 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -94,7 +94,7 @@ static int ce_compare_data(struct cache_entry *ce, struct stat *st)
 	if (fd >= 0) {
 		unsigned char sha1[20];
 		if (!index_fd(sha1, fd, st, 0, OBJ_BLOB, ce->name))
-			match = hashcmp(sha1, ce->sha1);
+			match = hashcmp(sha1, ce_norm_sha1(ce));
 		/* index_fd() closed the file descriptor already */
 	}
 	return match;
-- 
1.7.0.4.369.g81e89

  parent reply	other threads:[~2010-04-16 16:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-16 16:09 [PATCH RFC 0/5] Patches to avoid reporting conversion changes Henrik Grubbström (Grubba)
2010-04-16 16:09 ` [PATCH RFC 1/5] sha1_file: Added index_blob() Henrik Grubbström (Grubba)
2010-04-16 16:09 ` [PATCH RFC 2/5] cache: Added ce_norm_sha1() and related cache_entry fields Henrik Grubbström (Grubba)
2010-04-16 16:10 ` [PATCH RFC 3/5] cache: Added index extension "NORM" Henrik Grubbström (Grubba)
2010-04-16 16:10 ` [PATCH RFC 4/5] reachable: Made the gc aware of the ce_norm_sha1 Henrik Grubbström (Grubba)
2010-04-16 16:10 ` Henrik Grubbström (Grubba) [this message]
2010-04-20  7:25   ` [PATCH RFC 5/5] cache: Use ce_norm_sha1() Junio C Hamano
2010-04-20 15:39     ` Henrik Grubbström
2010-04-20 19:12       ` Junio C Hamano
2010-04-25 11:25         ` Henrik Grubbström
2010-04-16 18:02 ` [PATCH RFC 0/5] Patches to avoid reporting conversion changes Jari Aalto
2010-04-16 18:06   ` Randal L. Schwartz
2010-04-17 19:32     ` Jari Aalto
2010-04-17 19:34       ` Randal L. Schwartz
2010-04-17 22:07         ` Sverre Rabbelier
2010-04-17 22:32           ` Jakub Narebski
2010-04-17 22:47             ` Sverre Rabbelier
2010-04-17 22:58               ` Randal L. Schwartz

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=c68d98b384086925da0194e560ae01d83a29f80c.1271432034.git.grubba@grubba.org \
    --to=grubba@grubba.org \
    --cc=git@vger.kernel.org \
    /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).