summaryrefslogtreecommitdiff
path: root/symlinks.c
diff options
context:
space:
mode:
authorLibravatar Johannes Schindelin <johannes.schindelin@gmx.de>2021-02-12 15:49:55 +0100
committerLibravatar Johannes Schindelin <johannes.schindelin@gmx.de>2021-02-12 15:49:55 +0100
commit97d1dcb1efb2899a40b42da894f2ead0eb7af7ef (patch)
tree7de169ab45412319a20499c29c8ef1f36d6b7032 /symlinks.c
parentGit 2.25.4 (diff)
parentGit 2.24.4 (diff)
downloadtgif-97d1dcb1efb2899a40b42da894f2ead0eb7af7ef.tar.xz
Sync with 2.24.4
* maint-2.24: Git 2.24.4 Git 2.23.4 Git 2.22.5 Git 2.21.4 Git 2.20.5 Git 2.19.6 Git 2.18.5 Git 2.17.6 unpack_trees(): start with a fresh lstat cache run-command: invalidate lstat cache after a command finished checkout: fix bug that makes checkout follow symlinks in leading path
Diffstat (limited to 'symlinks.c')
-rw-r--r--symlinks.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/symlinks.c b/symlinks.c
index 69d458a24d..7dbb6b23d9 100644
--- a/symlinks.c
+++ b/symlinks.c
@@ -267,6 +267,13 @@ int has_dirs_only_path(const char *name, int len, int prefix_len)
*/
static int threaded_has_dirs_only_path(struct cache_def *cache, const char *name, int len, int prefix_len)
{
+ /*
+ * Note: this function is used by the checkout machinery, which also
+ * takes care to properly reset the cache when it performs an operation
+ * that would leave the cache outdated. If this function starts caching
+ * anything else besides FL_DIR, remember to also invalidate the cache
+ * when creating or deleting paths that might be in the cache.
+ */
return lstat_cache(cache, name, len,
FL_DIR|FL_FULLPATH, prefix_len) &
FL_DIR;
@@ -321,3 +328,20 @@ void remove_scheduled_dirs(void)
{
do_remove_scheduled_dirs(0);
}
+
+void invalidate_lstat_cache(void)
+{
+ reset_lstat_cache(&default_cache);
+}
+
+#undef rmdir
+int lstat_cache_aware_rmdir(const char *path)
+{
+ /* Any change in this function must be made also in `mingw_rmdir()` */
+ int ret = rmdir(path);
+
+ if (!ret)
+ invalidate_lstat_cache();
+
+ return ret;
+}