Merge branch 'dt/unpack-trees-cache-tree-revalidate'
authorJunio C Hamano <gitster@pobox.com>
Wed, 12 Aug 2015 21:09:57 +0000 (14:09 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Aug 2015 21:09:57 +0000 (14:09 -0700)
The code to perform multi-tree merges has been taught to repopulate
the cache-tree upon a successful merge into the index, so that
subsequent "diff-index --cached" (hence "status") and "write-tree"
(hence "commit") will go faster.

The same logic in "git checkout" may now be removed, but that is a
separate issue.

* dt/unpack-trees-cache-tree-revalidate:
unpack-trees: populate cache-tree on successful merge

t/t0090-cache-tree.sh
unpack-trees.c
index 601d02d71f735b4247528cc45b0ea055299ee7a0..055cc19000784bdb820e7ae53ba48987ead0367a 100755 (executable)
@@ -199,6 +199,30 @@ test_expect_success 'checkout -B gives cache-tree' '
        test_cache_tree
 '
 
+test_expect_success 'merge --ff-only maintains cache-tree' '
+       git checkout current &&
+       git checkout -b changes &&
+       test_commit llamas &&
+       test_commit pachyderm &&
+       test_cache_tree &&
+       git checkout current &&
+       test_cache_tree &&
+       git merge --ff-only changes &&
+       test_cache_tree
+'
+
+test_expect_success 'merge maintains cache-tree' '
+       git checkout current &&
+       git checkout -b changes2 &&
+       test_commit alpacas &&
+       test_cache_tree &&
+       git checkout current &&
+       test_commit struthio &&
+       test_cache_tree &&
+       git merge changes2 &&
+       test_cache_tree
+'
+
 test_expect_success 'partial commit gives cache-tree' '
        git checkout -b partial no-children &&
        test_commit one &&
index d6cf84904f189a284b4bd1d72c09ee975207700e..261804e666b77b22d69227562c3ec03365202f53 100644 (file)
@@ -1160,6 +1160,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 {