Skip to content

Commit 456156d

Browse files
committed
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 <[email protected]>
1 parent b9d37a5 commit 456156d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

builtin-read-tree.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,14 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
199199
* "-m ent" or "--reset ent" form), we can obtain a fully
200200
* valid cache-tree because the index must match exactly
201201
* what came from the tree.
202+
*
203+
* The same holds true if we are switching between two trees
204+
* using read-tree -m A B. The index must match B after that.
202205
*/
203206
if (nr_trees == 1 && !opts.prefix)
204207
prime_cache_tree(&active_cache_tree, trees[0]);
208+
else if (nr_trees == 2 && opts.merge)
209+
prime_cache_tree(&active_cache_tree, trees[1]);
205210

206211
if (write_cache(newfd, active_cache, active_nr) ||
207212
commit_locked_index(&lock_file))

0 commit comments

Comments
 (0)