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

Re: [PATCH v3] Enable minimal stat checking

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Jan 22, 2013, 08:25 UTC
Message-ID
<50FE4CEB.5040200@viscovery.net>
In-Reply-To
<1358840962-12316-1-git-send-email-robin.rosenberg@dewire.com>
Am 1/22/2013 8:49, schrieb Robin Rosenberg:
Show 9 quoted lines
> Specifically the fields uid, gid, ctime, ino and dev are set to zero
> by JGit. Other implementations, eg. Git in cygwin are allegedly also
> somewhat incompatible with Git For Windows and on *nix platforms
> the resolution of the timestamps may differ.
> 
> Any stat checking by git will then need to check content, which may
> be very slow, particularly on Windows. Since mtime and size
> is typically enough we should allow the user to tell git to avoid
> checking these fields if they are set to zero in the index.

Isn't this paragraph about slowness in the commit message misleading, as what the patch does has no influence on the speed of stat checking? Am I missing something?

> This change introduces a core.checkstat config option where the
> the user can select to check all fields (default), or just size
> and the whole second part of mtime (minimal).
Show 5 quoted lines
> +core.checkstat::
> +	Determines which stat fields to match between the index
> +	and work tree. The user can set this to 'default' or
> +	'minimal'. Default (or explicitly 'default'), is to check
> +	all fields, including the sub-second part of mtime and ctime.

I think this needs some more clarification, less 1337 speak, as well as a hint when to set the option.

	Determines which file attributes are checked to detect whether
	a file has been modified. Set this option to 'minimal', when...,
	which checks only the file size and whole-seconds of the last
	modification time. Otherwise, leave unset or set to the value
	'default'.

By starting with the hint when to set to 'minimal' in this way allows us to omit a specification what the 'default' is.

Show 13 quoted lines
> diff --git a/read-cache.c b/read-cache.c
> index fda78bc..23db681 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -197,21 +197,25 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
>  	}
>  	if (ce->ce_mtime.sec != (unsigned int)st->st_mtime)
>  		changed |= MTIME_CHANGED;
> -	if (trust_ctime && ce->ce_ctime.sec != (unsigned int)st->st_ctime)
> -		changed |= CTIME_CHANGED;
> +	if (trust_ctime ? check_stat : trust_ctime/*false*/)
> +		if (ce->ce_ctime.sec != (unsigned int)st->st_ctime)
> +			changed |= CTIME_CHANGED;

It took me a while to understand why you write /*false*/ there. Isn't the the condition merely this:

	if (trust_ctime && check_stat &&
	    ce->ce_ctime.sec != (unsigned int)st->st_ctime)
		changed |= CTIME_CHANGED;
Show 10 quoted lines
>  
>  #ifdef USE_NSEC
> -	if (ce->ce_mtime.nsec != ST_MTIME_NSEC(*st))
> +	if (check_stat && ce->ce_mtime.nsec != ST_MTIME_NSEC(*st))
>  		changed |= MTIME_CHANGED;
> -	if (trust_ctime && ce->ce_ctime.nsec != ST_CTIME_NSEC(*st))
> -		changed |= CTIME_CHANGED;
> +	if (trust_ctime ? check_stat : trust_ctime/*false*/)
> +		if (ce->ce_ctime.nsec != ST_CTIME_NSEC(*st))
> +			changed |= CTIME_CHANGED;
Same here.
>  #endif
-- Hannes
Previous: Robin RosenbergNext: Torsten Bögershausen
Message 18 of 29 in “Perform minimal stat comparison when some stat fields are not set”
  1. Perform minimal stat comparison when some stat fields are not setRobin Rosenberg, Dec 5, 2012
  2. Junio C HamanoDec 5, 2012
  3. Robin RosenbergDec 6, 2012
  4. Johannes SixtDec 6, 2012
  5. Robin RosenbergDec 6, 2012
  6. Make git selectively and conditionally ignore certain stat fieldsRobin Rosenberg, Jan 14, 2013
  7. Junio C HamanoJan 14, 2013
  8. Robin RosenbergJan 14, 2013
  9. Junio C HamanoJan 15, 2013
  10. Robin RosenbergJan 15, 2013
  11. Johannes SixtJan 15, 2013
  12. Robin RosenbergJan 15, 2013
  13. Junio C HamanoJan 15, 2013
  14. Ramsay JonesJan 16, 2013
  15. Robin RosenbergJan 20, 2013
  16. Junio C HamanoJan 20, 2013
  17. Enable minimal stat checkingRobin Rosenberg, Jan 22, 2013
  18. Johannes SixtJan 22, 2013
  19. Torsten BögershausenJan 22, 2013
  20. Junio C HamanoJan 22, 2013
  21. Robin RosenbergJan 22, 2013
  22. Jeff KingMay 6, 2013
  23. Junio C HamanoMay 7, 2013
  24. deprecate core.statinfo at Git 2.0 boundaryJunio C Hamano, May 7, 2013
  25. Junio C HamanoMay 7, 2013
  26. Jeff KingMay 7, 2013
  27. Robin RosenbergMay 7, 2013
  28. Make git selectively and conditionally ignore certain stat fieldsRobin Rosenberg, Jan 14, 2013
  29. Junio C HamanoJan 14, 2013

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.