summaryrefslogtreecommitdiff
path: root/fsmonitor.h
diff options
context:
space:
mode:
authorJeff Hostetler <jeffhost@microsoft.com>2022-05-26 21:47:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-05-26 22:59:27 (GMT)
commitf954c7b8ff3f1443dfd52b5d0c59208a8d1d87ec (patch)
tree89658b76389dfa6cc0ca28bc3d4374a8d401b9f1 /fsmonitor.h
parent7667f9d2ae944dbea85aeda7093af5c87904245c (diff)
downloadgit-f954c7b8ff3f1443dfd52b5d0c59208a8d1d87ec.zip
git-f954c7b8ff3f1443dfd52b5d0c59208a8d1d87ec.tar.gz
git-f954c7b8ff3f1443dfd52b5d0c59208a8d1d87ec.tar.bz2
fsmonitor: never set CE_FSMONITOR_VALID on submodules
Never set CE_FSMONITOR_VALID on the cache-entry of submodule directories. During a client command like 'git status', we may need to recurse into each submodule to compute a status summary for the submodule. Since the purpose of the ce_flag is to let Git avoid scanning a cache-entry, setting the flag causes the recursive call to be avoided and we report incorrect (no status) for the submodule. We created an OS watch on the root directory of our working directory and we receive events for everything in the cone under it. When submodules are present inside our working directory, we receive events for both our repo (the super) and any subs within it. Since our index doesn't have any information for items within the submodules, we can't use those events. We could try to truncate the paths of those events back to the submodule boundary and mark the GITLINK as dirty, but that feels expensive since we would have to prefix compare every FS event that we receive against a list of submodule roots. And it still wouldn't be sufficient to correctly report status on the submodule, since we don't have any space in the cache-entry to cache the submodule's status (the 'SCMU' bits in porcelain V2 speak). That is, the CE_FSMONITOR_VALID bit just says that we don't need to scan/inspect it because we already know the answer -- it doesn't say that the item is clean -- and we don't have space in the cache-entry to store those answers. So we should always do the recursive scan. Therefore, we should never set the flag on GITLINK cache-entries. Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fsmonitor.h')
-rw-r--r--fsmonitor.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/fsmonitor.h b/fsmonitor.h
index 3f41f65..edf7ce5 100644
--- a/fsmonitor.h
+++ b/fsmonitor.h
@@ -68,6 +68,15 @@ static inline int is_fsmonitor_refreshed(const struct index_state *istate)
* Set the given cache entries CE_FSMONITOR_VALID bit. This should be
* called any time the cache entry has been updated to reflect the
* current state of the file on disk.
+ *
+ * However, never mark submodules as valid. When commands like "git
+ * status" run they might need to recurse into the submodule (using a
+ * child process) to get a summary of the submodule state. We don't
+ * have (and don't want to create) the facility to translate every
+ * FS event that we receive and that happens to be deep inside of a
+ * submodule back to the submodule root, so we cannot correctly keep
+ * track of this bit on the gitlink directory. Therefore, we never
+ * set it on submodules.
*/
static inline void mark_fsmonitor_valid(struct index_state *istate, struct cache_entry *ce)
{
@@ -75,6 +84,8 @@ static inline void mark_fsmonitor_valid(struct index_state *istate, struct cache
if (fsm_mode > FSMONITOR_MODE_DISABLED &&
!(ce->ce_flags & CE_FSMONITOR_VALID)) {
+ if (S_ISGITLINK(ce->ce_mode))
+ return;
istate->cache_changed = 1;
ce->ce_flags |= CE_FSMONITOR_VALID;
trace_printf_key(&trace_fsmonitor, "mark_fsmonitor_clean '%s'", ce->name);