unpack-trees: reuse (still valid) cache-tree from src_index
[gitweb.git] / unpack-trees.c
index dbef6e1b8a2fbd0ed8af9c082c1f1b3e57e8a1f9..aa80b65ee15e221cbb9bf535fe03c0b3d4420b62 100644 (file)
@@ -1576,6 +1576,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
 
        ret = check_updates(o) ? (-2) : 0;
        if (o->dst_index) {
+               move_index_extensions(&o->result, o->src_index);
                if (!ret) {
                        if (!o->result.cache_tree)
                                o->result.cache_tree = cache_tree();
@@ -1584,7 +1585,6 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
                                                  WRITE_TREE_SILENT |
                                                  WRITE_TREE_REPAIR);
                }
-               move_index_extensions(&o->result, o->src_index);
                discard_index(o->dst_index);
                *o->dst_index = o->result;
        } else {