aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/update-index.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-02-05 09:42:32 -0800
committerJunio C Hamano <gitster@pobox.com>2022-02-05 09:42:32 -0800
commitee52b35e503fda30a269212823cc3dc67c907af7 (patch)
tree8315a85199bb84f087c4468917cbc2c1fbf9f49c /builtin/update-index.c
parent1b4d9b4512ea5a4d76ac4af40e9a4ed4729403e3 (diff)
parent2ede073fd2287eb91af26484c2e7dafc15ecb7b7 (diff)
downloadgit-ee52b35e503fda30a269212823cc3dc67c907af7.tar.gz
Merge branch 'ms/update-index-racy'
"git update-index --refresh" has been taught to deal better with racy timestamps (just like "git status" already does). * ms/update-index-racy: update-index: refresh should rewrite index in case of racy timestamps t7508: add tests capturing racy timestamp handling t7508: fix bogus mtime verification test-lib: introduce API for verifying file mtime
Diffstat (limited to 'builtin/update-index.c')
-rw-r--r--builtin/update-index.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 187203e8bb..7e0a0d9bf8 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -787,6 +787,17 @@ static int refresh(struct refresh_params *o, unsigned int flag)
setup_work_tree();
read_cache();
*o->has_errors |= refresh_cache(o->flags | flag);
+ if (has_racy_timestamp(&the_index)) {
+ /*
+ * Even if nothing else has changed, updating the file
+ * increases the chance that racy timestamps become
+ * non-racy, helping future run-time performance.
+ * We do that even in case of "errors" returned by
+ * refresh_cache() as these are no actual errors.
+ * cmd_status() does the same.
+ */
+ active_cache_changed |= SOMETHING_CHANGED;
+ }
return 0;
}