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

Re: [PATCH 3/3] cache-tree: Write index with updated cache-tree after commit

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 30, 2014, 18:10 UTC
Message-ID
<xmqqegy6z2t0.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1403914856-3546-3-git-send-email-dturner@twitter.com>
David Turner <dturner@twopensource.com> writes:
Show 33 quoted lines
> During the commit process, the cache-tree is updated. We need to write
> this updated cache-tree so that it's ready for subsequent commands.
>
> Add test code which demonstrates that git commit now writes the cache
> tree.  Also demonstrate that  cache-tree invalidation is correct.
>
> Signed-off-by: David Turner <dturner@twitter.com>
> ---
>  builtin/commit.c      |  6 ++++++
>  t/t0090-cache-tree.sh | 50 +++++++++++++++++++++++++++++++++++++++++++++++---
>  2 files changed, 53 insertions(+), 3 deletions(-)
>
> diff --git a/builtin/commit.c b/builtin/commit.c
> index 9cfef6c..6814e87 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -607,6 +607,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
>  	const char *hook_arg2 = NULL;
>  	int clean_message_contents = (cleanup_mode != CLEANUP_NONE);
>  	int old_display_comment_prefix;
> +	static struct lock_file index_lock;
> +	int index_fd;
>  
>  	/* This checks and barfs if author is badly specified */
>  	determine_author_info(author_ident);
> @@ -872,6 +874,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
>  		error(_("Error building trees"));
>  		return 0;
>  	}
> +	/* After updating the cache-tree, rewrite the index */
> +	index_fd = hold_locked_index(&index_lock, 0);
> +	if (index_fd >= 0 && write_index(&the_index, index_fd) >= 0)
> +		commit_locked_index(&index_lock);

Is this run unconditionally even when we are making a partial commit out of a temporary index file (which will be discarded after we create this commit)?

I have a feeling that a better place to populate the cache-tree may be prepare-index which knows the distinction between various modes of commit, but I haven't looked at the code path for a while...

Previous: David TurnerNext: Duy Nguyen
Message 4 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.