mirror of
https://github.com/git/git
synced 2024-10-02 14:45:21 +00:00
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>
This commit is contained in:
parent
29fbbf43a0
commit
ff03836b9d
23
fsmonitor.c
23
fsmonitor.c
|
@ -190,14 +190,35 @@ int fsmonitor_is_trivial_response(const struct strbuf *query_result)
|
||||||
return is_trivial;
|
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 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));
|
int pos = index_name_pos(istate, name, strlen(name));
|
||||||
|
|
||||||
if (pos >= 0) {
|
if (pos >= 0) {
|
||||||
struct cache_entry *ce = istate->cache[pos];
|
struct cache_entry *ce = istate->cache[pos];
|
||||||
ce->ce_flags &= ~CE_FSMONITOR_VALID;
|
ce->ce_flags &= ~CE_FSMONITOR_VALID;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mark the untracked cache dirty even if it wasn't found in the index
|
* Mark the untracked cache dirty even if it wasn't found in the index
|
||||||
|
|
Loading…
Reference in a new issue