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

Re: [PATCH 1/3] cache-tree: Create/update cache-tree on checkout

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 30, 2014, 06:31 UTC
Message-ID
<xmqqvbrizz63.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1403914856-3546-1-git-send-email-dturner@twitter.com>
David Turner <dturner@twopensource.com> writes:
Show 23 quoted lines
> When git checkout checks out a branch, create or update the
> cache-tree so that subsequent operations are faster.
>
> Signed-off-by: David Turner <dturner@twitter.com>
> ---
>  builtin/checkout.c    |  4 ++++
>  cache-tree.c          | 22 ++++++++++++----------
>  cache-tree.h          |  1 +
>  t/t0090-cache-tree.sh | 15 ++++++++++++++-
>  4 files changed, 31 insertions(+), 11 deletions(-)
>
> diff --git a/builtin/checkout.c b/builtin/checkout.c
> index 07cf555..df791e8 100644
> --- a/builtin/checkout.c
> +++ b/builtin/checkout.c
> @@ -553,6 +553,10 @@ static int merge_working_tree(const struct checkout_opts *opts,
>  		}
>  	}
>  
> +	if (write_cache_as_tree(NULL, WRITE_TREE_DO_NOT_WRITE, "")) {
> +		warn("Unable to write cache_tree");
> +	}
> +

This is not even warn-worthy event, isn't it? "checkout -m other" would attempt a three-way merge to replay your local changes relative to your current HEAD in the context of "other" branch and will leave conflicts in the index and in the working tree, and it is perfectly a normal thing that you cannot write the index in such a state as a tree object. Perhaps you should check if the index is unmerged before even attempting to compute the cache tree.

Also it looks very strange that write-cache-as-tree, whose *PRIMARY* function is to write a tree, receives a "DO NOT WRITE" option here. I understand that you want a new interface into the cache-tree subsystem that only updates the cache-tree but it somehow smells like a sloppy/lazy refactoring that is not done quite right.

Previous: Junio C Hamano
Message 7 of 7 in “cache-tree: Create/update cache-tree on checkout”
  1. 1/3 cache-tree: Create/update cache-tree on checkoutDavid Turner, Jun 28, 2014
  2. 2/3 test-dump-cache-tree: Improve output format and exit codeDavid Turner, Jun 28, 2014
  3. 3/3 cache-tree: Write index with updated cache-tree after commitDavid Turner, Jun 28, 2014
  4. Junio C HamanoJun 30, 2014
  5. Duy NguyenJun 29, 2014
  6. Junio C HamanoJun 30, 2014
  7. Junio C HamanoJun 30, 2014

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.