git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/4] read-tree -m A B: prime cache-tree from the switched-to tree

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 20, 2009, 10:58 UTC
Message-ID
<1240225100-29960-4-git-send-email-gitster@pobox.com>
In-Reply-To
<1240225100-29960-3-git-send-email-gitster@pobox.com>

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>
---
 builtin-read-tree.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 9cd7d07..391d709 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))
-- 
1.6.3.rc1.18.g66996
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 6 in “Revisiting cache-tree”
  1. 0/4 Revisiting cache-treeJunio C Hamano, Apr 20, 2009
  2. 1/4 read-tree A B: do not corrupt cache-treeJunio C Hamano, Apr 20, 2009
  3. 2/4 Move prime_cache_tree() to cache-tree.cJunio C Hamano, Apr 20, 2009
  4. 3/4 read-tree -m A B: prime cache-tree from the switched-to treeJunio C Hamano, Apr 20, 2009
  5. 4/4 checkout branch: prime cache-tree fullyJunio C Hamano, Apr 20, 2009
  6. Alex RiesenApr 20, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.