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

Re: [PATCH 5/5] reset: update cache-tree data when appropriate

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 6, 2011, 23:13 UTC
Message-ID
<7v62hte1k7.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1385c10084ae41ae4543ef3ccaa1d6c8182b2204.1323191497.git.trast@student.ethz.ch>
Thomas Rast <trast@student.ethz.ch> writes:
Show 32 quoted lines
> In the case of --mixed and --hard, we throw away the old index and
> rebuild everything from the tree argument (or HEAD).  So we have an
> opportunity here to fill in the cache-tree data, just as read-tree
> did.
>
> Signed-off-by: Thomas Rast <trast@student.ethz.ch>
> ---
>  builtin/reset.c       |    7 +++++++
>  t/t0090-cache-tree.sh |    4 ++--
>  2 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/reset.c b/builtin/reset.c
> index 811e8e2..8c2c1d5 100644
> --- a/builtin/reset.c
> +++ b/builtin/reset.c
> @@ -43,6 +43,7 @@ static int reset_index_file(const unsigned char *sha1, int reset_type, int quiet
>  	int nr = 1;
>  	int newfd;
>  	struct tree_desc desc[2];
> +	struct tree *tree;
>  	struct unpack_trees_options opts;
>  	struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
>  
> @@ -84,6 +85,12 @@ static int reset_index_file(const unsigned char *sha1, int reset_type, int quiet
>  		return error(_("Failed to find tree of %s."), sha1_to_hex(sha1));
>  	if (unpack_trees(nr, desc, &opts))
>  		return -1;
> +
> +	if (reset_type == MIXED || reset_type == HARD) {
> +		tree = parse_tree_indirect(sha1);
> +		prime_cache_tree(&active_cache_tree, tree);
> +	}

The basic idea that MIXED or HARD should result in a cache-tree that match the tree we just read is sound, but how expensive is prime_cache_tree()? I think it reads the same tree once again. Admittedly, the data needed to reconstruct the tree is likely to be hot in core, but it may be necessary to measure before deciding if this is a good change.

Previous: Thomas RastNext: Thomas Rast
Message 8 of 10 in “cache-tree revisited”
  1. 0/5 cache-tree revisitedThomas Rast, Dec 6, 2011
  2. 1/5 Add test-scrap-cache-treeThomas Rast, Dec 6, 2011
  3. Junio C HamanoDec 6, 2011
  4. 2/5 Test the current state of the cache-tree optimizationThomas Rast, Dec 6, 2011
  5. 3/5 Refactor cache_tree_update idiom from commitThomas Rast, Dec 6, 2011
  6. 4/5 commit: write cache-tree data when writing index anywayThomas Rast, Dec 6, 2011
  7. 5/5 reset: update cache-tree data when appropriateThomas Rast, Dec 6, 2011
  8. Junio C HamanoDec 6, 2011
  9. Thomas RastDec 7, 2011
  10. Thomas RastDec 8, 2011

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.