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:
authorNipunn Koorapati <nipunn@dropbox.com>2021-03-18 00:22:22 +0300
committerJunio C Hamano <gitster@pobox.com>2021-03-18 23:31:13 +0300
commit0ec9949f78e348250f55ba0343344ec8c606be11 (patch)
tree929a8a2d49ce004cf9c1e3503d4525b5741509d3 /fsmonitor.h
parent4f3d6d026176a48991c4e5ff95c8db583af38148 (diff)
fsmonitor: add assertion that fsmonitor is valid to check_removed
Validate that fsmonitor is valid to futureproof against bugs where check_removed might be called from places that haven't refreshed. Signed-off-by: Nipunn Koorapati <nipunn@dropbox.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 7f1794b90b..f20d72631d 100644
--- a/fsmonitor.h
+++ b/fsmonitor.h
@@ -50,6 +50,17 @@ void refresh_fsmonitor(struct index_state *istate);
int fsmonitor_is_trivial_response(const struct strbuf *query_result);
/*
+ * Check if refresh_fsmonitor has been called at least once.
+ * refresh_fsmonitor is idempotent. Returns true if fsmonitor is
+ * not enabled (since the state will be "fresh" w/ CE_FSMONITOR_VALID unset)
+ * This version is useful for assertions
+ */
+static inline int is_fsmonitor_refreshed(const struct index_state *istate)
+{
+ return !core_fsmonitor || istate->fsmonitor_has_run_once;
+}
+
+/*
* 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.