summaryrefslogtreecommitdiff
path: root/builtin-read-tree.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-04-20 03:58:19 -0700
committerJunio C Hamano <gitster@pobox.com>2009-04-20 04:16:41 -0700
commit456156dc068b7664c08e35157e17a6440ec68f32 (patch)
tree23ecc7cf69a6e9143b278152505ab62ca21e976d /builtin-read-tree.c
parentb9d37a5420446d0db2dc0dc5458a5e50656a4852 (diff)
downloadgit-456156dc068b7664c08e35157e17a6440ec68f32.tar.gz
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 <gitster@pobox.com>
Diffstat (limited to 'builtin-read-tree.c')
-rw-r--r--builtin-read-tree.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 9cd7d0738e..391d709704 100644
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
@@ -199,9 +199,14 @@ 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))