Thread (11 messages) 11 messages, 3 authors, 2021-03-17

Re: [PATCH 2/3] fsmonitor: add assertion that fsmonitor is valid to check_removed

flat view

From: Eric Sunshine <hidden>
Date: 2021-03-14 22:36:14

On Sun, Mar 14, 2021 at 6:19 PM Nipunn Koorapati via GitGitGadget
[off-list ref] wrote:
quoted hunk ↗ jump to hunk
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 <redacted>
---
diff --git a/fsmonitor.h b/fsmonitor.h
@@ -49,6 +49,17 @@ void refresh_fsmonitor(struct index_state *istate);
+/*
+ * 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;
+}
Unusual 4-space indentation rather than typical 1-tab.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help