On Sun, Mar 14, 2021 at 6:19 PM Nipunn Koorapati via GitGitGadget <gitgitgadget@xxxxxxxxx> wrote: > 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@xxxxxxxxxxx> > --- > 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.