]> git.ipfire.org Git - thirdparty/git.git/blobdiff - unpack-trees.c
Merge branch 'js/fsmonitor-unpack-fix'
[thirdparty/git.git] / unpack-trees.c
index af6e9b9c2fd558dc625ddd8f63b54c9e8d489e56..9298fe1d9b3feb695f3ea6a36e0531e7399f3f23 100644 (file)
@@ -417,6 +417,9 @@ static int check_updates(struct unpack_trees_options *o,
 
        progress = get_progress(o, index);
 
+       /* Start with clean cache to avoid using any possibly outdated info. */
+       invalidate_lstat_cache();
+
        git_attr_set_direction(GIT_ATTR_CHECKOUT);
 
        if (should_update_submodules())
@@ -1549,14 +1552,10 @@ static void mark_new_skip_worktree(struct pattern_list *pl,
 static void populate_from_existing_patterns(struct unpack_trees_options *o,
                                            struct pattern_list *pl)
 {
-       char *sparse = git_pathdup("info/sparse-checkout");
-
-       pl->use_cone_patterns = core_sparse_checkout_cone;
-       if (add_patterns_from_file_to_list(sparse, "", 0, pl, NULL) < 0)
+       if (get_sparse_checkout_patterns(pl) < 0)
                o->skip_sparse_checkout = 1;
        else
                o->pl = pl;
-       free(sparse);
 }
 
 
@@ -1613,8 +1612,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
        o->merge_size = len;
        mark_all_ce_unused(o->src_index);
 
-       if (o->src_index->fsmonitor_last_update)
-               o->result.fsmonitor_last_update = o->src_index->fsmonitor_last_update;
+       o->result.fsmonitor_last_update =
+               xstrdup_or_null(o->src_index->fsmonitor_last_update);
 
        /*
         * Sparse checkout loop #1: set NEW_SKIP_WORKTREE on existing entries
@@ -1726,8 +1725,6 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
                if (!ret) {
                        if (git_env_bool("GIT_TEST_CHECK_CACHE_TREE", 0))
                                cache_tree_verify(the_repository, &o->result);
-                       if (!o->result.cache_tree)
-                               o->result.cache_tree = cache_tree();
                        if (!cache_tree_fully_valid(o->result.cache_tree))
                                cache_tree_update(&o->result,
                                                  WRITE_TREE_SILENT |