Fast-path 'update-index --refresh' a bit.
If the length in the stat information does not match what is recorded in the index, there is no point rehashing the contents to see if the index entry can be refreshed. We need to be a bit careful. Immediately after read-tree or checkout-index without -u, ce_size is set to zero and does not match the length of the blob that is recorded, and we need to actually look at the contents to see if it has been changed. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Sep 19, 2005 at 14:49 UTC
1991b223c05d45d2a915842990b2a7c4819dcbcf
1 file changed
+7
update-index.c
+7
@@ -184,6 +184,13 @@ static struct cache_entry *refresh_entry(struct cache_entry *ce)
184
if (changed & (MODE_CHANGED | TYPE_CHANGED))
185
return ERR_PTR(-EINVAL);
186
187
+ /* Immediately after read-tree or update-index --cacheinfo,
188
+ * the length field is zero. For other cases the ce_size
189
+ * should match the SHA1 recorded in the index entry.
190
+ */
191
+ if ((changed & DATA_CHANGED) && ce->ce_size != htonl(0))
192
+ return ERR_PTR(-EINVAL);
193
+
194
switch (st.st_mode & S_IFMT) {
195
case S_IFREG:
196
if (compare_data(ce, &st))