]> git.ipfire.org Git - thirdparty/git.git/commit - fsmonitor.c
fsmonitor: never set CE_FSMONITOR_VALID on submodules
authorJeff Hostetler <jeffhost@microsoft.com>
Thu, 26 May 2022 21:47:17 +0000 (21:47 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 26 May 2022 22:59:27 +0000 (15:59 -0700)
commitf954c7b8ff3f1443dfd52b5d0c59208a8d1d87ec
tree89658b76389dfa6cc0ca28bc3d4374a8d401b9f1
parent7667f9d2ae944dbea85aeda7093af5c87904245c
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>
fsmonitor.c
fsmonitor.h
t/t7527-builtin-fsmonitor.sh