Skip to content

Commit 070c57d

Browse files
committed
Merge branch 'rr/minimal-stat'
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
2 parents 7b51969 + c08e4d5 commit 070c57d

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed

Documentation/config.txt

+6
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,12 @@ core.trustctime::
235235
crawlers and some backup systems).
236236
See linkgit:git-update-index[1]. True by default.
237237

238+
core.checkstat::
239+
Determines which stat fields to match between the index
240+
and work tree. The user can set this to 'default' or
241+
'minimal'. Default (or explicitly 'default'), is to check
242+
all fields, including the sub-second part of mtime and ctime.
243+
238244
core.quotepath::
239245
The commands that output paths (e.g. 'ls-files',
240246
'diff'), when not given the `-z` option, will quote

cache.h

+1
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ extern int delete_ref(const char *, const unsigned char *sha1, int delopt);
536536
/* Environment bits from configuration mechanism */
537537
extern int trust_executable_bit;
538538
extern int trust_ctime;
539+
extern int check_stat;
539540
extern int quote_path_fully;
540541
extern int has_symlinks;
541542
extern int minimum_abbrev, default_abbrev;

config.c

+6
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,12 @@ static int git_default_core_config(const char *var, const char *value)
566566
trust_ctime = git_config_bool(var, value);
567567
return 0;
568568
}
569+
if (!strcmp(var, "core.statinfo")) {
570+
if (!strcasecmp(value, "default"))
571+
check_stat = 1;
572+
else if (!strcasecmp(value, "minimal"))
573+
check_stat = 0;
574+
}
569575

570576
if (!strcmp(var, "core.quotepath")) {
571577
quote_path_fully = git_config_bool(var, value);

environment.c

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
int trust_executable_bit = 1;
1515
int trust_ctime = 1;
16+
int check_stat = 1;
1617
int has_symlinks = 1;
1718
int minimum_abbrev = 4, default_abbrev = 7;
1819
int ignore_case;

read-cache.c

+14-10
Original file line numberDiff line numberDiff line change
@@ -197,30 +197,34 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
197197
}
198198
if (ce->ce_mtime.sec != (unsigned int)st->st_mtime)
199199
changed |= MTIME_CHANGED;
200-
if (trust_ctime && ce->ce_ctime.sec != (unsigned int)st->st_ctime)
200+
if (trust_ctime && check_stat &&
201+
ce->ce_ctime.sec != (unsigned int)st->st_ctime)
201202
changed |= CTIME_CHANGED;
202203

203204
#ifdef USE_NSEC
204-
if (ce->ce_mtime.nsec != ST_MTIME_NSEC(*st))
205+
if (check_stat && ce->ce_mtime.nsec != ST_MTIME_NSEC(*st))
205206
changed |= MTIME_CHANGED;
206-
if (trust_ctime && ce->ce_ctime.nsec != ST_CTIME_NSEC(*st))
207+
if (trust_ctime && check_stat &&
208+
ce->ce_ctime.nsec != ST_CTIME_NSEC(*st))
207209
changed |= CTIME_CHANGED;
208210
#endif
209211

210-
if (ce->ce_uid != (unsigned int) st->st_uid ||
211-
ce->ce_gid != (unsigned int) st->st_gid)
212-
changed |= OWNER_CHANGED;
213-
if (ce->ce_ino != (unsigned int) st->st_ino)
214-
changed |= INODE_CHANGED;
212+
if (check_stat) {
213+
if (ce->ce_uid != (unsigned int) st->st_uid ||
214+
ce->ce_gid != (unsigned int) st->st_gid)
215+
changed |= OWNER_CHANGED;
216+
if (ce->ce_ino != (unsigned int) st->st_ino)
217+
changed |= INODE_CHANGED;
218+
}
215219

216220
#ifdef USE_STDEV
217221
/*
218222
* st_dev breaks on network filesystems where different
219223
* clients will have different views of what "device"
220224
* the filesystem is on
221225
*/
222-
if (ce->ce_dev != (unsigned int) st->st_dev)
223-
changed |= INODE_CHANGED;
226+
if (check_stat && ce->ce_dev != (unsigned int) st->st_dev)
227+
changed |= INODE_CHANGED;
224228
#endif
225229

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

0 commit comments

Comments
 (0)