tests: fix GIT_TEST_INSTALLED's PATH to include t/helper/
[gitweb.git] / read-cache.c
index 1df5c16dbc31d444b98478bc892821bf1e2dda85..8c924506dd96037c1d7c0fa93e4223f9274a851f 100644 (file)
@@ -345,7 +345,7 @@ static int is_racy_stat(const struct index_state *istate,
                );
 }
 
-static int is_racy_timestamp(const struct index_state *istate,
+int is_racy_timestamp(const struct index_state *istate,
                             const struct cache_entry *ce)
 {
        return (!S_ISGITLINK(ce->ce_mode) &&
@@ -1496,6 +1496,12 @@ int refresh_index(struct index_state *istate, unsigned int flags,
        typechange_fmt = (in_porcelain ? "T\t%s\n" : "%s needs update\n");
        added_fmt = (in_porcelain ? "A\t%s\n" : "%s needs update\n");
        unmerged_fmt = (in_porcelain ? "U\t%s\n" : "%s: needs merge\n");
+       /*
+        * Use the multi-threaded preload_index() to refresh most of the
+        * cache entries quickly then in the single threaded loop below,
+        * we only have to do the special cases that are left.
+        */
+       preload_index(istate, pathspec, 0);
        for (i = 0; i < istate->cache_nr; i++) {
                struct cache_entry *ce, *new_entry;
                int cache_errno = 0;
@@ -2297,8 +2303,8 @@ int read_index_from(struct index_state *istate, const char *path,
        freshen_shared_index(base_path, 0);
        merge_base_index(istate);
        post_read_index_from(istate);
-       free(base_path);
        trace_performance_leave("read cache %s", base_path);
+       free(base_path);
        return ret;
 }