git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Perform minimal stat comparison when some stat fields are not set
@ 2012-12-05 21:20 Robin Rosenberg
  2012-12-05 23:43 ` Junio C Hamano
  0 siblings, 1 reply; 29+ messages in thread
From: Robin Rosenberg @ 2012-12-05 21:20 UTC (permalink / raw)
  To: git; +Cc: gitster, spearce, Robin Rosenberg

At least JGit does sets uid, gid, ctime, ino and dev fields to zero
on update. To Git this looks like the stat data does not match and
a full file compare will be forced even it size and mtime match. This
is in practice unnecessary. Sense JGit's presence by checking if ino
and dev is zero.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 read-cache.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index fda78bc..6f13a22 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -197,21 +197,26 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
 	}
 	if (ce->ce_mtime.sec != (unsigned int)st->st_mtime)
 		changed |= MTIME_CHANGED;
-	if (trust_ctime && ce->ce_ctime.sec != (unsigned int)st->st_ctime)
+
+	int minimal_stat = (ce->ce_ino == 0 && ce->ce_dev == 0);
+
+	if (trust_ctime && !minimal_stat && ce->ce_ctime.sec != (unsigned int)st->st_ctime)
 		changed |= CTIME_CHANGED;
 
 #ifdef USE_NSEC
 	if (ce->ce_mtime.nsec != ST_MTIME_NSEC(*st))
 		changed |= MTIME_CHANGED;
-	if (trust_ctime && ce->ce_ctime.nsec != ST_CTIME_NSEC(*st))
+	if (trust_ctime && !minimal_stat && ce->ce_ctime.nsec != ST_CTIME_NSEC(*st))
 		changed |= CTIME_CHANGED;
 #endif
 
-	if (ce->ce_uid != (unsigned int) st->st_uid ||
-	    ce->ce_gid != (unsigned int) st->st_gid)
-		changed |= OWNER_CHANGED;
-	if (ce->ce_ino != (unsigned int) st->st_ino)
-		changed |= INODE_CHANGED;
+	if (!minimal_stat) {
+		if (ce->ce_uid != (unsigned int) st->st_uid ||
+			ce->ce_gid != (unsigned int) st->st_gid)
+			changed |= OWNER_CHANGED;
+		if (ce->ce_ino != 0 && ce->ce_ino != (unsigned int) st->st_ino)
+			changed |= INODE_CHANGED;
+	}
 
 #ifdef USE_STDEV
 	/*
@@ -219,7 +224,7 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
 	 * clients will have different views of what "device"
 	 * the filesystem is on
 	 */
-	if (ce->ce_dev != (unsigned int) st->st_dev)
+	if (!minimal_stat && ce->ce_dev != (unsigned int) st->st_dev)
 		changed |= INODE_CHANGED;
 #endif
 
-- 
1.8.0.msysgit.0.dirty

^ permalink raw reply related	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2013-05-07 20:37 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-05 21:20 [PATCH] Perform minimal stat comparison when some stat fields are not set Robin Rosenberg
2012-12-05 23:43 ` Junio C Hamano
2012-12-06  1:09   ` Robin Rosenberg
2012-12-06  7:21     ` Johannes Sixt
2012-12-06 11:16       ` Robin Rosenberg
2013-01-14 21:11       ` [PATCH v2] Make git selectively and conditionally ignore certain stat fields Robin Rosenberg
2013-01-14 21:57         ` Junio C Hamano
2013-01-14 23:43           ` Robin Rosenberg
2013-01-15  0:11             ` Junio C Hamano
2013-01-15  0:43               ` Robin Rosenberg
2013-01-15  7:02               ` Johannes Sixt
2013-01-15  7:09               ` Robin Rosenberg
2013-01-15  8:12                 ` Junio C Hamano
2013-01-16 20:14                   ` Ramsay Jones
2013-01-20 19:51                   ` Robin Rosenberg
2013-01-20 20:30                     ` Junio C Hamano
2013-01-22  7:49                       ` [PATCH v3] Enable minimal stat checking Robin Rosenberg
2013-01-22  8:25                         ` Johannes Sixt
2013-01-22 17:19                         ` Torsten Bögershausen
2013-01-22 17:21                         ` Junio C Hamano
2013-01-22 20:38                           ` Robin Rosenberg
2013-05-06 23:22                         ` Jeff King
2013-05-07  4:54                           ` Junio C Hamano
2013-05-07  5:31                             ` [PATCH] deprecate core.statinfo at Git 2.0 boundary Junio C Hamano
2013-05-07  6:38                               ` Junio C Hamano
2013-05-07 14:09                               ` Jeff King
2013-05-07 20:29                                 ` Robin Rosenberg
2013-01-14 23:51           ` [PATCH v3] Make git selectively and conditionally ignore certain stat fields Robin Rosenberg
2013-01-14 22:08         ` [PATCH v2] " Junio C Hamano

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).