summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2022-02-05 09:42:32 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2022-02-05 09:42:32 -0800
commitee52b35e503fda30a269212823cc3dc67c907af7 (patch)
tree8315a85199bb84f087c4468917cbc2c1fbf9f49c /builtin
parentMerge branch 'jc/reflog-parse-options' (diff)
parentupdate-index: refresh should rewrite index in case of racy timestamps (diff)
downloadtgif-ee52b35e503fda30a269212823cc3dc67c907af7.tar.xz
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')
-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;
}