summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2998138)
raw | patch | inline | side by side (parent: 2998138)
author | Junio C Hamano <gitster@pobox.com> | |
Fri, 9 Jul 2010 00:27:43 +0000 (17:27 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 9 Jul 2010 00:27:43 +0000 (17:27 -0700) |
In 456156d a shortcut to priming the index tree reference was
introduced, but the justification for it was completely bogus.
"read-tree -m A B" is to take the index (and the working tree)
that is largely based on (but does not have to match exactly) A
and update it to B, while carrying the local change that does
not overlap the difference between A and B, so there is no reason
to expect that the resulting index should match the tree B.
Noticed and test provided by Heiko Voigt.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
introduced, but the justification for it was completely bogus.
"read-tree -m A B" is to take the index (and the working tree)
that is largely based on (but does not have to match exactly) A
and update it to B, while carrying the local change that does
not overlap the difference between A and B, so there is no reason
to expect that the resulting index should match the tree B.
Noticed and test provided by Heiko Voigt.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-read-tree.c | patch | blob | history | |
t/t1001-read-tree-m-2way.sh | patch | blob | history |
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 82e25eaa0758d8b9584592f4072f81eeccb0bf1d..4fbf5f82ae541ea31954ecfed0f908e471910549 100644 (file)
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
* "-m ent" or "--reset ent" form), we can obtain a fully
* valid cache-tree because the index must match exactly
* what came from the tree.
- *
- * The same holds true if we are switching between two trees
- * using read-tree -m A B. The index must match B after that.
*/
if (nr_trees == 1 && !opts.prefix)
prime_cache_tree(&active_cache_tree, trees[0]);
- else if (nr_trees == 2 && opts.merge)
- prime_cache_tree(&active_cache_tree, trees[1]);
if (write_cache(newfd, active_cache, active_nr) ||
commit_locked_index(&lock_file))
index 271bc4e17f0c12cda550ffa4f54f1ad7555b3bed..6e3b60110381bca4cbd235f73b5c5b837b57a512 100755 (executable)
git ls-files --stage | tee >treeMcheck.out &&
test_cmp treeM.out treeMcheck.out'
+test_expect_success '-m references the correct modified tree' '
+ echo >file-a &&
+ echo >file-b &&
+ git add file-a file-b &&
+ git commit -a -m "test for correct modified tree"
+ git branch initial-mod &&
+ echo b >file-b &&
+ git commit -a -m "B" &&
+ echo a >file-a &&
+ git add file-a &&
+ git ls-tree $(git write-tree) file-a >expect &&
+ git read-tree -m HEAD initial-mod &&
+ git ls-tree $(git write-tree) file-a >actual &&
+ test_cmp expect actual
+'
+
test_done