git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Kristian Høgsberg" <krh@redhat.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>, git@vger.kernel.org
Subject: Re: [PATCH] builtin-commit: Refresh cache after adding files.
Date: Fri, 09 Nov 2007 13:39:56 -0500	[thread overview]
Message-ID: <1194633596.30909.18.camel@hinata.boston.redhat.com> (raw)
In-Reply-To: <7vhcjvtgz5.fsf@gitster.siamese.dyndns.org>


On Fri, 2007-11-09 at 10:24 -0800, Junio C Hamano wrote:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > On Fri, 9 Nov 2007, Kristian Høgsberg wrote:
> >
> >> This fixes the race in the last test int t3700.
> >
> > Well, it is not a race.  My fault.  I thought it was.
> >
> > What you basically did was to make sure that the index is up-to-date after 
> > adding the files.  You might even want to say that in the commit message, 
> > and only then say that it fixes t3700, too.
> 
> Ah, it all makes sense.  I should have been more relaxed and
> careful when I first read your t3700 patch.
> 
> If this were a breakage in racy-git-avoidance code, then
> refresh_cache() Kristian added (or "add --refresh" immediately
> after "git commit" in the test script) would have been fooled by
> the same raciness and wouldn't have changed a thing.
> 
> This discussion exposes a problem with add_files_to_cache()
> function.
> 
> Try this in a clean repository that tracks Makefile:
> 
> 	$ git diff-files --name-only    ;# no output
>         $ touch Makefile
>         $ git diff-files --name-only
> 	Makefile
>         $ git add -u
>         $ git diff-files --name-only
> 	Makefile
>         $ git add Makefile
>         $ git diff-files --name-only    ;# no output
> 
> I think this is a broken behaviour.  As long as we are adding
> the contents from a path on the filesystem to the corresponding
> location in the index, it should sync the stat bits for the
> entry in the index with the filesystem to make the entry
> stat-clean.  IOW, we should not see stat-dirtiness reported
> after "add -u".

Yup, that's what I expected, and why I couldn't quite understand why the
refresh was necessary.

> The funny thing is that add_files_to_cache() run by "git add -u"
> calls add_file_to_cache() to add the updated contents for
> touched paths, but the latter function is used in the more
> explicit "git add Makefile" codepath, without any magic
> postprocessing after the function returns to sync the stat
> info.  IOW, both "add -u" and "add Makefile" ends up calling
> add_file_to_cache("Makefile") and I do not see why we are
> getting different results.

There is some timing involved in this, which may explain the different
results you see.  On my laptop I can trigger the add_files_to_cache()
problem roughly 4 out of 5 times, but on my faster desktop, it can't
trigger it.

> And add_file_to_cache(), which calls add_file_to_index() on
> the_index, does call the fill_stat_cache_info() to sync the stat
> information by itself, as it should be.  I am still puzzled with
> this.
> 
> So I think Kristian's two refresh_cache() do fix the issue, but
> at the same time I _think_ it is a workaround for broken
> add_files_to_cache() behaviour, which is what we should fix.

OK, I'll resend the patch with a better description, and add a refresh
call for the user index too, for the git commit <file> case.

cheers,
Kristian

  reply	other threads:[~2007-11-09 18:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-09 16:40 [PATCH] builtin-commit: Refresh cache after adding files Kristian Høgsberg
2007-11-09 17:05 ` Johannes Schindelin
2007-11-09 17:13   ` Kristian Høgsberg
2007-11-09 17:24     ` Johannes Schindelin
2007-11-09 17:38       ` Kristian Høgsberg
2007-11-09 18:24   ` Junio C Hamano
2007-11-09 18:39     ` Kristian Høgsberg [this message]
2007-11-10  1:40     ` *[PATCH] " Junio C Hamano
2007-11-10  2:02       ` Johannes Schindelin
2007-11-10  2:26         ` Junio C Hamano
2007-11-10  2:22     ` [PATCH] git-add: make the entry stat-clean after re-adding the same contents Junio C Hamano
2007-11-10  2:43       ` Linus Torvalds
2007-11-10  9:01         ` [PATCH 1/2] ce_match_stat, run_diff_files: use symbolic constants for readability Junio C Hamano
2007-11-10  9:02         ` [PATCH 2/2] git-add: make the entry stat-clean after re-adding the same contents Junio C Hamano

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=1194633596.30909.18.camel@hinata.boston.redhat.com \
    --to=krh@redhat.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).