summaryrefslogtreecommitdiff
path: root/entry.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-01-26 01:13:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-01-26 01:13:34 (GMT)
commit0990e7aaaa63ca908dbdfc379af132068e4b066f (patch)
treedb4ecb6c21e8949a7735201f0fbfe0bcc25ed784 /entry.c
parent9847a524321afbfa6dbb08bfd9b6a0746f965578 (diff)
parentbda6eb0da9b4e4e763b531c83cab9fd9f85934ff (diff)
downloadgit-0990e7aaaa63ca908dbdfc379af132068e4b066f.zip
git-0990e7aaaa63ca908dbdfc379af132068e4b066f.tar.gz
git-0990e7aaaa63ca908dbdfc379af132068e4b066f.tar.bz2
Merge branch 'kb/lstat-cache'
* kb/lstat-cache: lstat_cache(): introduce clear_lstat_cache() function lstat_cache(): introduce invalidate_lstat_cache() function lstat_cache(): introduce has_dirs_only_path() function lstat_cache(): introduce has_symlink_or_noent_leading_path() function lstat_cache(): more cache effective symlink/directory detection
Diffstat (limited to 'entry.c')
-rw-r--r--entry.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/entry.c b/entry.c
index 5f24816..05aa58d 100644
--- a/entry.c
+++ b/entry.c
@@ -9,35 +9,25 @@ static void create_directories(const char *path, const struct checkout *state)
const char *slash = path;
while ((slash = strchr(slash+1, '/')) != NULL) {
- struct stat st;
- int stat_status;
-
len = slash - path;
memcpy(buf, path, len);
buf[len] = 0;
- if (len <= state->base_dir_len)
- /*
- * checkout-index --prefix=<dir>; <dir> is
- * allowed to be a symlink to an existing
- * directory.
- */
- stat_status = stat(buf, &st);
- else
- /*
- * if there currently is a symlink, we would
- * want to replace it with a real directory.
- */
- stat_status = lstat(buf, &st);
-
- if (!stat_status && S_ISDIR(st.st_mode))
+ /*
+ * For 'checkout-index --prefix=<dir>', <dir> is
+ * allowed to be a symlink to an existing directory,
+ * and we set 'state->base_dir_len' below, such that
+ * we test the path components of the prefix with the
+ * stat() function instead of the lstat() function.
+ */
+ if (has_dirs_only_path(len, buf, state->base_dir_len))
continue; /* ok, it is already a directory. */
/*
- * We know stat_status == 0 means something exists
- * there and this mkdir would fail, but that is an
- * error codepath; we do not care, as we unlink and
- * mkdir again in such a case.
+ * If this mkdir() would fail, it could be that there
+ * is already a symlink or something else exists
+ * there, therefore we then try to unlink it and try
+ * one more time to create the directory.
*/
if (mkdir(buf, 0777)) {
if (errno == EEXIST && state->force &&