aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-12-19 16:05:20 -0800
committerJunio C Hamano <gitster@pobox.com>2011-12-19 16:05:20 -0800
commit33e7fefef6b68b300870e04904ad1db48be9b580 (patch)
tree2ec6cf691b2f86aa0830c6f2927ac661bf3db87e /builtin
parent367d20ec6b9e8e297537f665fb528346bd0aff27 (diff)
parent6c52ec8a9ab48b50fc8bf9559467d5a4cf7eee3b (diff)
downloadgit-33e7fefef6b68b300870e04904ad1db48be9b580.tar.gz
git-33e7fefef6b68b300870e04904ad1db48be9b580.tar.xz
Merge branch 'tr/cache-tree'
* tr/cache-tree: reset: update cache-tree data when appropriate commit: write cache-tree data when writing index anyway Refactor cache_tree_update idiom from commit Test the current state of the cache-tree optimization Add test-scrap-cache-tree
Diffstat (limited to 'builtin')
-rw-r--r--builtin/commit.c7
-rw-r--r--builtin/reset.c7
2 files changed, 10 insertions, 4 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index f73ef9c86..039c04fe9 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -395,6 +395,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
fd = hold_locked_index(&index_lock, 1);
add_files_to_cache(also ? prefix : NULL, pathspec, 0);
refresh_cache_or_die(refresh_flags);
+ update_main_cache_tree(1);
if (write_cache(fd, active_cache, active_nr) ||
close_lock_file(&index_lock))
die(_("unable to write new_index file"));
@@ -415,6 +416,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
fd = hold_locked_index(&index_lock, 1);
refresh_cache_or_die(refresh_flags);
if (active_cache_changed) {
+ update_main_cache_tree(1);
if (write_cache(fd, active_cache, active_nr) ||
commit_locked_index(&index_lock))
die(_("unable to write new_index file"));
@@ -863,10 +865,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
*/
discard_cache();
read_cache_from(index_file);
- if (!active_cache_tree)
- active_cache_tree = cache_tree();
- if (cache_tree_update(active_cache_tree,
- active_cache, active_nr, 0, 0) < 0) {
+ if (update_main_cache_tree(0)) {
error(_("Error building trees"));
return 0;
}
diff --git a/builtin/reset.c b/builtin/reset.c
index 811e8e252..8c2c1d52a 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -43,6 +43,7 @@ static int reset_index_file(const unsigned char *sha1, int reset_type, int quiet
int nr = 1;
int newfd;
struct tree_desc desc[2];
+ struct tree *tree;
struct unpack_trees_options opts;
struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
@@ -84,6 +85,12 @@ static int reset_index_file(const unsigned char *sha1, int reset_type, int quiet
return error(_("Failed to find tree of %s."), sha1_to_hex(sha1));
if (unpack_trees(nr, desc, &opts))
return -1;
+
+ if (reset_type == MIXED || reset_type == HARD) {
+ tree = parse_tree_indirect(sha1);
+ prime_cache_tree(&active_cache_tree, tree);
+ }
+
if (write_cache(newfd, active_cache, active_nr) ||
commit_locked_index(lock))
return error(_("Could not write new index file."));