[PATCH] Re-instate index file write optimization
This makes "git-update-index" avoid the new index file write if it didn't make any changes to the index. It still doesn't make things like "git status" be read-only operations in general, but if the index file doesn't need refreshing, it now will at least avoid making unnecessary changes. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Linus Torvalds committed
Oct 1, 2005 at 13:39 UTC
5cd5ace72bf8944c920a20a7b98c82f7ed663d8a
1 file changed
+5
-3
update-index.c
+5
-3
@@ -391,9 +391,11 @@ int main(int argc, const char **argv)
391
update_one(buf.buf, prefix, prefix_length);
392
}
393
}
394
- if (write_cache(newfd, active_cache, active_nr) ||
395
- commit_index_file(&cache_file))
396
- die("Unable to write new cachefile");
394
+ if (active_cache_changed) {
395
+ if (write_cache(newfd, active_cache, active_nr) ||
396
+ commit_index_file(&cache_file))
397
+ die("Unable to write new cachefile");
398
+ }
399
400
return has_errors ? 1 : 0;
401
}