Junio C Hamano  committed 456156d

read-tree -m A B: prime cache-tree from the switched-to tree

When switching to a new branch with "read-tree -m A B", the resulting
index must match tree B and we can prime the cache tree with it.

Signed-off-by: Junio C Hamano <>

  • Participants
  • Parent commits b9d37a5
  • Branches master

Comments (0)

Files changed (1)

File 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) ||