]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jc/read-tree-cache-tree-fix'
authorJunio C Hamano <gitster@pobox.com>
Wed, 14 Jul 2010 16:34:23 +0000 (09:34 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Jul 2010 16:34:23 +0000 (09:34 -0700)
* jc/read-tree-cache-tree-fix:
  Fix "read-tree -m A B" priming the cache-tree

builtin/read-tree.c
t/t1001-read-tree-m-2way.sh

index 8bdcab11389e8b4facab355f27f0e1926134b86f..9ad1e66916545dd2aeeb110661e56edfa5921019 100644 (file)
@@ -219,14 +219,9 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
         * "-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 6327d205cb89b00e77502031e3b56b4b895cc32d..0c562bb820cb747a8f0d0df1eabb39da0b9eea21 100755 (executable)
@@ -390,4 +390,20 @@ test_expect_success \
      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