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

1  2 
unpack-trees.c
diff --combined unpack-trees.c
index d6cf84904f189a284b4bd1d72c09ee975207700e,d92f903402f0f8c448b689d26d3d5a97afc56f67..261804e666b77b22d69227562c3ec03365202f53
@@@ -9,7 -9,6 +9,7 @@@
  #include "refs.h"
  #include "attr.h"
  #include "split-index.h"
 +#include "dir.h"
  
  /*
   * Error messages expected by scripts out of plumbing commands such as
@@@ -224,9 -223,6 +224,9 @@@ static int check_updates(struct unpack_
                struct cache_entry *ce = index->cache[i];
  
                if (ce->ce_flags & CE_UPDATE) {
 +                      if (ce->ce_flags & CE_WT_REMOVE)
 +                              die("BUG: both update and delete flags are set on %s",
 +                                  ce->name);
                        display_progress(progress, ++cnt);
                        ce->ce_flags &= ~CE_UPDATE;
                        if (o->update && !o->dry_run) {
@@@ -296,7 -292,6 +296,7 @@@ static int apply_sparse_checkout(struc
                if (!(ce->ce_flags & CE_UPDATE) && verify_uptodate_sparse(ce, o))
                        return -1;
                ce->ce_flags |= CE_WT_REMOVE;
 +              ce->ce_flags &= ~CE_UPDATE;
        }
        if (was_skip_worktree && !ce_skip_worktree(ce)) {
                if (verify_absent_sparse(ce, ERROR_WOULD_LOSE_UNTRACKED_OVERWRITTEN, o))
@@@ -1160,6 -1155,14 +1160,14 @@@ int unpack_trees(unsigned len, struct t
        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 {
@@@ -1264,10 -1267,8 +1272,10 @@@ static int verify_uptodate_sparse(cons
  static void invalidate_ce_path(const struct cache_entry *ce,
                               struct unpack_trees_options *o)
  {
 -      if (ce)
 -              cache_tree_invalidate_path(o->src_index, ce->name);
 +      if (!ce)
 +              return;
 +      cache_tree_invalidate_path(o->src_index, ce->name);
 +      untracked_cache_invalidate_path(o->src_index, ce->name);
  }
  
  /*