aboutsummaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorKjetil Barvik <barvik@broadpark.no>2009-01-18 16:14:52 +0100
committerJunio C Hamano <gitster@pobox.com>2009-01-18 13:54:54 -0800
commitbad4a54fa6fe8a9bbdfb5c3e413268eefde69b75 (patch)
tree6bb9c1f60d63ac3eff00b14cec6f7d5c32c04c62 /cache.h
parent09c9306658f793f2cad1ed7856b55a7c4e758703 (diff)
downloadgit-bad4a54fa6fe8a9bbdfb5c3e413268eefde69b75.tar.gz
git-bad4a54fa6fe8a9bbdfb5c3e413268eefde69b75.tar.xz
lstat_cache(): introduce has_dirs_only_path() function
The create_directories() function in entry.c currently calls stat() or lstat() for each path component of the pathname 'path' each and every time. For the 'git checkout' command, this function is called on each file for which we must do an update (ce->ce_flags & CE_UPDATE), so we get lots and lots of calls. To fix this, we make a new wrapper to the lstat_cache() function, and call the wrapper function instead of the calls to the stat() or the lstat() functions. Since the paths given to the create_directories() function, is sorted alphabetically, the new wrapper would be very cache effective in this situation. To support it we must update the lstat_cache() function to be able to say that "please test the complete length of 'name'", and also to give it the length of a prefix, where the cache should use the stat() function instead of the lstat() function to test each path component. Thanks to Junio C Hamano, Linus Torvalds and Rene Scharfe for valuable comments to this patch! Signed-off-by: Kjetil Barvik <barvik@broadpark.no> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/cache.h b/cache.h
index 11181aa00..7c8c8e484 100644
--- a/cache.h
+++ b/cache.h
@@ -721,6 +721,7 @@ struct checkout {
extern int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath);
extern int has_symlink_leading_path(int len, const char *name);
extern int has_symlink_or_noent_leading_path(int len, const char *name);
+extern int has_dirs_only_path(int len, const char *name, int prefix_len);
extern struct alternate_object_database {
struct alternate_object_database *next;