Skip to content

Commit

Permalink
Merge branch 'rr/minimal-stat'
Browse files Browse the repository at this point in the history
Some reimplementations of Git does not write all the stat info back
to the index due to their implementation limitations (e.g. jgit
running on Java).  A configuration option can tell Git to ignore
changes to most of the stat fields and only pay attention to mtime
and size, which these implementations can reliably update.  This
avoids excessive revalidation of contents.

* rr/minimal-stat:
  Enable minimal stat checking
  • Loading branch information
Junio C Hamano committed Jan 30, 2013
2 parents 7b51969 + c08e4d5 commit 070c57d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
6 changes: 6 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ core.trustctime::
crawlers and some backup systems).
See linkgit:git-update-index[1]. True by default.

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.

core.quotepath::
The commands that output paths (e.g. 'ls-files',
'diff'), when not given the `-z` option, will quote
Expand Down
1 change: 1 addition & 0 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ extern int delete_ref(const char *, const unsigned char *sha1, int delopt);
/* Environment bits from configuration mechanism */
extern int trust_executable_bit;
extern int trust_ctime;
extern int check_stat;
extern int quote_path_fully;
extern int has_symlinks;
extern int minimum_abbrev, default_abbrev;
Expand Down
6 changes: 6 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,12 @@ static int git_default_core_config(const char *var, const char *value)
trust_ctime = git_config_bool(var, value);
return 0;
}
if (!strcmp(var, "core.statinfo")) {
if (!strcasecmp(value, "default"))
check_stat = 1;
else if (!strcasecmp(value, "minimal"))
check_stat = 0;
}

if (!strcmp(var, "core.quotepath")) {
quote_path_fully = git_config_bool(var, value);
Expand Down
1 change: 1 addition & 0 deletions environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

int trust_executable_bit = 1;
int trust_ctime = 1;
int check_stat = 1;
int has_symlinks = 1;
int minimum_abbrev = 4, default_abbrev = 7;
int ignore_case;
Expand Down
24 changes: 14 additions & 10 deletions read-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,30 +197,34 @@ 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)
if (trust_ctime && check_stat &&
ce->ce_ctime.sec != (unsigned int)st->st_ctime)
changed |= CTIME_CHANGED;

#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))
if (trust_ctime && check_stat &&
ce->ce_ctime.nsec != ST_CTIME_NSEC(*st))
changed |= CTIME_CHANGED;
#endif

if (ce->ce_uid != (unsigned int) st->st_uid ||
ce->ce_gid != (unsigned int) st->st_gid)
changed |= OWNER_CHANGED;
if (ce->ce_ino != (unsigned int) st->st_ino)
changed |= INODE_CHANGED;
if (check_stat) {
if (ce->ce_uid != (unsigned int) st->st_uid ||
ce->ce_gid != (unsigned int) st->st_gid)
changed |= OWNER_CHANGED;
if (ce->ce_ino != (unsigned int) st->st_ino)
changed |= INODE_CHANGED;
}

#ifdef USE_STDEV
/*
* st_dev breaks on network filesystems where different
* clients will have different views of what "device"
* the filesystem is on
*/
if (ce->ce_dev != (unsigned int) st->st_dev)
changed |= INODE_CHANGED;
if (check_stat && ce->ce_dev != (unsigned int) st->st_dev)
changed |= INODE_CHANGED;
#endif

if (ce->ce_size != (unsigned int) st->st_size)
Expand Down

0 comments on commit 070c57d

Please sign in to comment.