summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 11c8a74)
raw | patch | inline | side by side (parent: 11c8a74)
author | Thomas Rast <trast@student.ethz.ch> | |
Tue, 6 Dec 2011 17:43:39 +0000 (18:43 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 6 Dec 2011 23:13:39 +0000 (15:13 -0800) |
In the case of --mixed and --hard, we throw away the old index and
rebuild everything from the tree argument (or HEAD). So we have an
opportunity here to fill in the cache-tree data, just as read-tree
did.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
rebuild everything from the tree argument (or HEAD). So we have an
opportunity here to fill in the cache-tree data, just as read-tree
did.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/reset.c | patch | blob | history | |
t/t0090-cache-tree.sh | patch | blob | history |
diff --git a/builtin/reset.c b/builtin/reset.c
index 811e8e252c1c6a54e65179557203daf2bc42bdb9..8c2c1d52a227334a3d6456bf0989cd561628ffa0 100644 (file)
--- a/builtin/reset.c
+++ b/builtin/reset.c
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));
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."));
diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh
index a3527a5c99cc69a5f54eaf2ff4b20f8c239f55bc..f97256292e9f7d3f6cc69e790284382e09584921 100755 (executable)
--- a/t/t0090-cache-tree.sh
+++ b/t/t0090-cache-tree.sh
test_shallow_cache_tree
'
-test_expect_failure 'reset --hard gives cache-tree' '
+test_expect_success 'reset --hard gives cache-tree' '
test-scrap-cache-tree &&
git reset --hard &&
test_shallow_cache_tree
'
-test_expect_failure 'reset --hard without index gives cache-tree' '
+test_expect_success 'reset --hard without index gives cache-tree' '
rm -f .git/index &&
git reset --hard &&
test_shallow_cache_tree