From: Junio C Hamano Date: Wed, 12 Aug 2015 21:09:57 +0000 (-0700) Subject: Merge branch 'dt/unpack-trees-cache-tree-revalidate' X-Git-Tag: v2.6.0-rc0~74 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/9ad8474b986b0295df6ba1455daa611a7a49a49e?ds=inline;hp=-c Merge branch 'dt/unpack-trees-cache-tree-revalidate' 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 --- 9ad8474b986b0295df6ba1455daa611a7a49a49e diff --combined unpack-trees.c index d6cf84904f,d92f903402..261804e666 --- a/unpack-trees.c +++ b/unpack-trees.c @@@ -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); } /*