public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: David Turner <dturner@twopensource•com>
Cc: git@vger•kernel.org, David Turner <dturner@twitter•com>
Subject: Re: [PATCH 3/3] cache-tree: Write index with updated cache-tree after commit
Date: Mon, 30 Jun 2014 11:10:19 -0700	[thread overview]
Message-ID: <xmqqegy6z2t0.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1403914856-3546-3-git-send-email-dturner@twitter.com> (David Turner's message of "Fri, 27 Jun 2014 17:20:56 -0700")

David Turner <dturner@twopensource•com> writes:

> 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...

  reply	other threads:[~2014-06-30 18:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-28  0:20 [PATCH 1/3] cache-tree: Create/update cache-tree on checkout David Turner
2014-06-28  0:20 ` [PATCH 2/3] test-dump-cache-tree: Improve output format and exit code David Turner
2014-06-28  0:20 ` [PATCH 3/3] cache-tree: Write index with updated cache-tree after commit David Turner
2014-06-30 18:10   ` Junio C Hamano [this message]
2014-06-29  3:33 ` [PATCH 1/3] cache-tree: Create/update cache-tree on checkout Duy Nguyen
2014-06-30 18:13   ` Junio C Hamano
2014-06-30  6:31 ` Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2014-07-01  0:13 David Turner
2014-07-01  0:13 ` [PATCH 3/3] cache-tree: Write index with updated cache-tree after commit David Turner
2014-07-01  4:26   ` Torsten Bögershausen
2014-07-01  5:49     ` Johannes Sixt
2014-07-01 19:14 [PATCH 1/3] cache-tree: Create/update cache-tree on checkout David Turner
2014-07-01 19:14 ` [PATCH 3/3] cache-tree: Write index with updated cache-tree after commit David Turner
2014-07-01 22:45   ` Junio C Hamano
2014-07-01 22:58     ` David Turner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqegy6z2t0.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=dturner@twitter$(echo .)com \
    --cc=dturner@twopensource$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox