Merge branch 'sg/t3020-typofix'
[gitweb.git] / unpack-trees.c
index 7bb446a4afd5db0577d38ca84bf781a63e059c1c..bb09b1ed27a6c973c93f5ec855973e277279549f 100644 (file)
@@ -1162,6 +1162,14 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
        o->src_index = NULL;
        ret = check_updates(o) ? (-2) : 0;
        if (o->dst_index) {
+               if (!ret) {
+                       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 |
+                                                 WRITE_TREE_REPAIR);
+               }
                discard_index(o->dst_index);
                *o->dst_index = o->result;
        } else {