summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2015-03-08 10:12:35 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-03-12 20:45:16 (GMT)
commite931371a8f1164185486a1f5fdaaa708b4a6217c (patch)
tree54a324f4d02e1f14d9715029d652a742de48ba5c /dir.c
parentf9e6c649589e0940ccb82821107fb658277ed86b (diff)
downloadgit-e931371a8f1164185486a1f5fdaaa708b4a6217c.zip
git-e931371a8f1164185486a1f5fdaaa708b4a6217c.tar.gz
git-e931371a8f1164185486a1f5fdaaa708b4a6217c.tar.bz2
untracked cache: invalidate at index addition or removal
Ideally we should implement untracked_cache_remove_from_index() and untracked_cache_add_to_index() so that they update untracked cache right away instead of invalidating it and wait for read_directory() next time to deal with it. But that may need some more work in unpack-trees.c. So stay simple as the first step. The new call in add_index_entry_with_check() may look strange because new calls usually stay close to cache_tree_invalidate_path(). We do it a bit later than c_t_i_p() in this function because if it's about replacing the entry with the same name, we don't care (but cache-tree does). Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/dir.c b/dir.c
index b39a034..68b46d0 100644
--- a/dir.c
+++ b/dir.c
@@ -2502,3 +2502,34 @@ done2:
}
return uc;
}
+
+void untracked_cache_invalidate_path(struct index_state *istate,
+ const char *path)
+{
+ const char *sep;
+ struct untracked_cache_dir *d;
+ if (!istate->untracked || !istate->untracked->root)
+ return;
+ sep = strrchr(path, '/');
+ if (sep)
+ d = lookup_untracked(istate->untracked,
+ istate->untracked->root,
+ path, sep - path);
+ else
+ d = istate->untracked->root;
+ istate->untracked->dir_invalidated++;
+ d->valid = 0;
+ d->untracked_nr = 0;
+}
+
+void untracked_cache_remove_from_index(struct index_state *istate,
+ const char *path)
+{
+ untracked_cache_invalidate_path(istate, path);
+}
+
+void untracked_cache_add_to_index(struct index_state *istate,
+ const char *path)
+{
+ untracked_cache_invalidate_path(istate, path);
+}