]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t7519: avoid file to index mtime race for untracked cache
authorTao Klerks <tao@klerks.biz>
Sun, 27 Feb 2022 21:56:59 +0000 (21:56 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 28 Feb 2022 18:02:17 +0000 (10:02 -0800)
In t7519 there is a test that writes files to disk, and immediately
writes the index with the untracked cache. Because of
mtime-comparison logic that uses a 1-second resolution, this means
the cached entries are not trusted/used under some circumstances
(see read-cache.c#is_racy_stat()).

Untracked cache tests in t7063 use a 1-second delay to avoid this
issue, but we don't want to introduce arbitrary slowdowns, so instead
use test-tool chmtime to backdate the files slightly. The t7063
delays are a #leftoverbit, to be worked on in a separate series.

This change doesn't actually affect the outcome of the test, but does
enhance its validity, and becomes relevant after later changes.

Signed-off-by: Tao Klerks <tao@klerks.biz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7519-status-fsmonitor.sh

index a6308acf006c9e4d35e47578465e348bb213356f..3f984136ea96699a1616a62c38895f5b10411c99 100755 (executable)
@@ -324,13 +324,19 @@ test_expect_success UNTRACKED_CACHE 'ignore .git changes when invalidating UNTR'
                cd dot-git &&
                mkdir -p .git/hooks &&
                : >tracked &&
+               test-tool chmtime =-60 tracked &&
                : >modified &&
+               test-tool chmtime =-60 modified &&
                mkdir dir1 &&
                : >dir1/tracked &&
+               test-tool chmtime =-60 dir1/tracked &&
                : >dir1/modified &&
+               test-tool chmtime =-60 dir1/modified &&
                mkdir dir2 &&
                : >dir2/tracked &&
+               test-tool chmtime =-60 dir2/tracked &&
                : >dir2/modified &&
+               test-tool chmtime =-60 dir2/modified &&
                write_integration_script &&
                git config core.fsmonitor .git/hooks/fsmonitor-test &&
                git update-index --untracked-cache &&