use REALLOC_ARRAY for changing the allocation size of arrays
[gitweb.git] / builtin / checkout.c
index f71e74531d2a7d195ff2987f6dca3c69c636aa7c..8afdf2b5c4bfbd53e7315afe9d8ae3d88f93dd57 100644 (file)
@@ -552,6 +552,12 @@ 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(&the_index, WRITE_TREE_SILENT | WRITE_TREE_REPAIR);
+
        if (write_locked_index(&the_index, lock_file, COMMIT_LOCK))
                die(_("unable to write new index file"));