Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Willford <Kevin.Willford@microsoft.com>2021-02-03 18:34:49 +0300
committerJunio C Hamano <gitster@pobox.com>2021-02-17 04:14:35 +0300
commitff03836b9d696617d699da2e4108057f9a48b9ef (patch)
treead1ccea238e4c902418782fb691bf848be793321 /fsmonitor.c
parent29fbbf43a031cefb6fe6e3f723d78f82af4979b0 (diff)
fsmonitor: allow all entries for a folder to be invalidated
Allow fsmonitor to report directory changes by reporting paths with a trailing slash. Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Signed-off-by: Kevin Willford <Kevin.Willford@microsoft.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Reviewed-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fsmonitor.c')
-rw-r--r--fsmonitor.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/fsmonitor.c b/fsmonitor.c
index 3105dc370a..64deeda597 100644
--- a/fsmonitor.c
+++ b/fsmonitor.c
@@ -190,13 +190,34 @@ int fsmonitor_is_trivial_response(const struct strbuf *query_result)
return is_trivial;
}
-static void fsmonitor_refresh_callback(struct index_state *istate, const char *name)
+static void fsmonitor_refresh_callback(struct index_state *istate, char *name)
{
- int pos = index_name_pos(istate, name, strlen(name));
+ int i, len = strlen(name);
+ if (name[len - 1] == '/') {
+
+ /*
+ * TODO We should binary search to find the first path with
+ * TODO this directory prefix. Then linearly update entries
+ * TODO while the prefix matches. Taking care to search without
+ * TODO the trailing slash -- because '/' sorts after a few
+ * TODO interesting special chars, like '.' and ' '.
+ */
+
+ /* Mark all entries for the folder invalid */
+ for (i = 0; i < istate->cache_nr; i++) {
+ if (istate->cache[i]->ce_flags & CE_FSMONITOR_VALID &&
+ starts_with(istate->cache[i]->name, name))
+ istate->cache[i]->ce_flags &= ~CE_FSMONITOR_VALID;
+ }
+ /* Need to remove the / from the path for the untracked cache */
+ name[len - 1] = '\0';
+ } else {
+ int pos = index_name_pos(istate, name, strlen(name));
- if (pos >= 0) {
- struct cache_entry *ce = istate->cache[pos];
- ce->ce_flags &= ~CE_FSMONITOR_VALID;
+ if (pos >= 0) {
+ struct cache_entry *ce = istate->cache[pos];
+ ce->ce_flags &= ~CE_FSMONITOR_VALID;
+ }
}
/*