summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar David Turner <dturner@twopensource.com>2014-07-05 21:06:56 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2014-07-07 12:30:34 -0700
commitaecf567cbfb6ab46e82f7f5df36fb6a2dd5bee69 (patch)
treebb7e31b4b9ebe4adb3a78a9f2012815658b17ca3 /builtin
parentMerge branch 'maint-1.8.5' into maint (diff)
downloadtgif-aecf567cbfb6ab46e82f7f5df36fb6a2dd5bee69.tar.xz
cache-tree: create/update cache-tree on checkout
When git checkout checks out a branch, create or update the cache-tree so that subsequent operations are faster. update_main_cache_tree learned a new flag, WRITE_TREE_REPAIR. When WRITE_TREE_REPAIR is set, portions of the cache-tree which do not correspond to existing tree objects are invalidated (and portions which do are marked as valid). No new tree objects are created. Signed-off-by: David Turner <dturner@twitter.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/checkout.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 07cf555309..054214fe43 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -553,6 +553,14 @@ static int merge_working_tree(const struct checkout_opts *opts,
}
}
+ if (!active_cache_tree)
+ active_cache_tree = cache_tree();
+
+ if (!cache_tree_fully_valid(active_cache_tree))
+ cache_tree_update(active_cache_tree,
+ (const struct cache_entry * const *)active_cache,
+ active_nr, WRITE_TREE_SILENT | WRITE_TREE_REPAIR);
+
if (write_cache(newfd, active_cache, active_nr) ||
commit_locked_index(lock_file))
die(_("unable to write new index file"));