test-lib: introduce test_commit_bulk
[gitweb.git] / fsmonitor.c
index 0af7c4edba37fd9f6a8cee83cd2715c3fa08b488..1dee0aded1c433c7cfb90195328f270559c9b421 100644 (file)
@@ -97,19 +97,13 @@ void write_fsmonitor_extension(struct strbuf *sb, struct index_state *istate)
 static int query_fsmonitor(int version, uint64_t last_update, struct strbuf *query_result)
 {
        struct child_process cp = CHILD_PROCESS_INIT;
-       char ver[64];
-       char date[64];
-       const char *argv[4];
 
-       if (!(argv[0] = core_fsmonitor))
+       if (!core_fsmonitor)
                return -1;
 
-       snprintf(ver, sizeof(version), "%d", version);
-       snprintf(date, sizeof(date), "%" PRIuMAX, (uintmax_t)last_update);
-       argv[1] = ver;
-       argv[2] = date;
-       argv[3] = NULL;
-       cp.argv = argv;
+       argv_array_push(&cp.args, core_fsmonitor);
+       argv_array_pushf(&cp.args, "%d", version);
+       argv_array_pushf(&cp.args, "%" PRIuMAX, (uintmax_t)last_update);
        cp.use_shell = 1;
        cp.dir = get_git_work_tree();
 
@@ -130,12 +124,11 @@ static void fsmonitor_refresh_callback(struct index_state *istate, const char *n
         * as it could be a new untracked file.
         */
        trace_printf_key(&trace_fsmonitor, "fsmonitor_refresh_callback '%s'", name);
-       untracked_cache_invalidate_path(istate, name);
+       untracked_cache_invalidate_path(istate, name, 0);
 }
 
 void refresh_fsmonitor(struct index_state *istate)
 {
-       static int has_run_once = 0;
        struct strbuf query_result = STRBUF_INIT;
        int query_success = 0;
        size_t bol; /* beginning of line */
@@ -143,9 +136,9 @@ void refresh_fsmonitor(struct index_state *istate)
        char *buf;
        int i;
 
-       if (!core_fsmonitor || has_run_once)
+       if (!core_fsmonitor || istate->fsmonitor_has_run_once)
                return;
-       has_run_once = 1;
+       istate->fsmonitor_has_run_once = 1;
 
        trace_printf_key(&trace_fsmonitor, "refresh fsmonitor");
        /*
@@ -185,6 +178,9 @@ void refresh_fsmonitor(struct index_state *istate)
                for (i = 0; i < istate->cache_nr; i++)
                        istate->cache[i]->ce_flags &= ~CE_FSMONITOR_VALID;
 
+               /* If we're going to check every file, ensure we save the results */
+               istate->cache_changed |= FSMONITOR_CHANGED;
+
                if (istate->untracked)
                        istate->untracked->use_fsmonitor = 0;
        }