From: Linus Torvalds Date: Wed, 01 Feb 2006 02:09:32 GMT Subject: Re: [Census] So who uses git? Message-ID: In-Reply-To: On Tue, 31 Jan 2006, Linus Torvalds wrote: > > We still have one unused bit in the cache-entry "ce_flags", so we wouldn't > even need to break any existing index files with it. In case it wasn't clear, the _core_ of this optimization would be as simple as something like the appended. The real meat is just making sure that CE_VALID gets set/cleared properly. (That's also the most complex part, of course, but this trivial patch might help show the basic idea) Linus --- diff --git a/cache.h b/cache.h index bdbe2d6..7adc2e6 100644 --- a/cache.h +++ b/cache.h @@ -91,6 +91,7 @@ struct cache_entry { #define CE_NAMEMASK (0x0fff) #define CE_STAGEMASK (0x3000) #define CE_UPDATE (0x4000) +#define CE_VALID (0x8000) #define CE_STAGESHIFT 12 #define create_ce_flags(len, stage) htons((len) | ((stage) << CE_STAGESHIFT)) diff --git a/read-cache.c b/read-cache.c index c5474d4..738fe78 100644 --- a/read-cache.c +++ b/read-cache.c @@ -148,7 +148,16 @@ static int ce_match_stat_basic(struct ca int ce_match_stat(struct cache_entry *ce, struct stat *st) { - unsigned int changed = ce_match_stat_basic(ce, st); + unsigned int changed; + + /* + * If it's marked as always valid in the index, it's + * valid whatever the checked-out copy says + */ + if (ce->ce_flags & htons(CE_VALID)) + return 0; + + changed = ce_match_stat_basic(ce, st); /* * Within 1 second of this sequence: