]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/checkout.c
cache-tree: create/update cache-tree on checkout
[thirdparty/git.git] / builtin / checkout.c
index 07cf55530918e8de6ae45e1c9b7e16707c32f844..054214fe43c8f8e3b815d4afb747408f2524c378 100644 (file)
@@ -553,6 +553,14 @@ static int merge_working_tree(const struct checkout_opts *opts,
                }
        }
 
+       if (!active_cache_tree)
+               active_cache_tree = cache_tree();
+
+       if (!cache_tree_fully_valid(active_cache_tree))
+               cache_tree_update(active_cache_tree,
+                                 (const struct cache_entry * const *)active_cache,
+                                 active_nr, WRITE_TREE_SILENT | WRITE_TREE_REPAIR);
+
        if (write_cache(newfd, active_cache, active_nr) ||
            commit_locked_index(lock_file))
                die(_("unable to write new index file"));