git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: Alex Riesen <raa.lkml@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH] Fix update-index --refresh for submodules if stat(2) returns st_size 0
Date: Tue, 22 Jul 2008 10:28:46 -0700	[thread overview]
Message-ID: <7vy73tltf5.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <4885897C.8010401@viscovery.net> (Johannes Sixt's message of "Tue, 22 Jul 2008 09:17:16 +0200")

Johannes Sixt <j.sixt@viscovery.net> writes:

>> +	if ((changed & DATA_CHANGED) && (ce->ce_size != 0 || S_ISGITLINK(ce->ce_mode)))
>
> Does this mean that ce->ce_size is non-zero for gitlinks, at least on
> Unix? Is this value useful in anyway? I don't think so. Then it shouldn't
> be a random value that lstat() happens to return.

These ce_xxx fields are the values we read from lstat(2) when the user
told us to stage that working tree entity, be it a regular file, a
symlink, or a directory that is a submodule.  The only thing required for
them is that they are stable (i.e. if you haven't touched the working tree
entity, the value stays the same), and changes across modification.  The
value itself does not have to "mean" anything.

When trying to see if the user has changes in the working tree entity
since the last such staging of the path, we compare that value with what
comes back from lstat(2), before actually comparing the contents.  If the
filesize changed, they cannot be the same and the code says you have
modified it without having to look at the contents.

	Side note.  This is why you need to be careful after modifying
	autocrlf related configuration and attributes.  If you had CRLF
	contents in the working tree that was incorrectly staged as-is,
	then switch autocrlf-on, and "git add" to fix the staged copy to
	be LF-terminated, we say "it's unchanged and we do not bother
	rehashing" by comparing the ce_xxx fields without looking at the
	contents (this is an absolutely necessary optimization to make
	"git add ."  usable), because ce_size records the size of CRLF
	version you have in the working tree, and you haven't changed the
	working tree file in this sequence above.

        Removing the file and checking things out would be the most
	straightforward solution in such a case.

We used to include ce_dev (taken from struct stat.st_dev) in the list of
fields to cache and compare to detect changes, but that is now excluded
because it is not stable (see comments in read-cache.c).  If the directory
size is unstable, perhaps it would be better to force it to some fixed
magic value so that it is not used by this "quick change detection" check.

If you network-mount the same directory from POSIX and windows, the former
may give "storage size of the directory" while the latter may give 0.
This would mean that you would need a "update-index --refresh" when you
switch between such machines.

  parent reply	other threads:[~2008-07-22 17:29 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-21 17:35 [PATCH] Fix update-index --refresh for submodules if stat(2) returns st_size 0 Alex Riesen
2008-07-21 18:20 ` Johannes Schindelin
2008-07-21 19:43   ` Alex Riesen
2008-07-21 23:26     ` Johannes Schindelin
2008-07-22  8:07     ` Junio C Hamano
2008-07-22 16:49       ` Alex Riesen
2008-07-22  7:17 ` Johannes Sixt
2008-07-22 16:46   ` Alex Riesen
2008-07-22 16:59     ` Johannes Sixt
2008-07-22 17:28   ` Junio C Hamano [this message]
2008-07-22 19:39     ` [PATCH] Build configuration to skip ctime for modification test Alex Riesen
2008-07-22 20:17       ` Johannes Schindelin
2008-07-22 20:31         ` Alex Riesen
2008-07-23  0:12           ` Junio C Hamano
2008-07-23 16:46             ` Alex Riesen
2008-07-23 16:59               ` Johannes Schindelin
2008-07-23 19:16                 ` Alex Riesen
2008-07-25  2:00                   ` Linus Torvalds
2008-07-25  5:55                     ` Alex Riesen
2008-07-26  0:57                       ` Johannes Schindelin
2008-07-26 15:38                         ` [PATCH] Make use of stat.ctime configurable Alex Riesen
2008-07-27 19:46                           ` Junio C Hamano
2008-07-27 19:46                           ` Junio C Hamano
2008-07-28  6:31                             ` Alex Riesen
2008-07-28 16:04                               ` David Brown
2008-07-28 16:09                                 ` Linus Torvalds
2008-07-28 21:49                                   ` Alex Riesen
2008-07-29  1:16                                   ` Junio C Hamano
2008-07-29  1:23                                     ` Linus Torvalds
2008-07-29  1:31                                       ` Junio C Hamano
2008-07-29  1:41                                         ` David Brown
2008-07-29  2:49                                           ` Junio C Hamano
2008-07-29 10:45                                           ` Johannes Schindelin
2008-07-29  1:55                                         ` Linus Torvalds
2008-07-29  2:01                                           ` Linus Torvalds
2008-07-29 10:49                                       ` Johannes Schindelin
2008-07-28 16:20                               ` Petr Baudis
2008-07-28 21:47                                 ` [PATCH] Improve the placement of core.trustctime in the documentation Alex Riesen
2008-07-29  6:23                                   ` Junio C Hamano
2008-07-24 19:00             ` [PATCH] Do not use ctime if file mode is not used Alex Riesen
2008-07-23 16:00           ` git svn throws locale related error when built from source Anton Mostovoy

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=7vy73tltf5.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=j.sixt@viscovery.net \
    --cc=raa.lkml@gmail.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).