t7508: add tests capturing racy timestamp handling

"git status" fixes racy timestamps regardless of the worktree being dirty or not. The new test cases capture this behavior. Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Marc Strapetz committed Jan 7, 2022 at 11:17 UTC 9b71efd01489d6c93436740e4c1b3eadeb0c719b
1 file changed +22
t/t7508-status.sh
+22
@@ -1654,4 +1654,26 @@ test_expect_success '--no-optional-locks prevents index update' '
1654 ! test_is_magic_mtime .git/index
1655 '
1656
1657 +test_expect_success 'racy timestamps will be fixed for clean worktree' '
1658 + echo content >racy-dirty &&
1659 + echo content >racy-racy &&
1660 + git add racy* &&
1661 + git commit -m "racy test files" &&
1662 + # let status rewrite the index, if necessary; after that we expect
1663 + # no more index writes unless caused by racy timestamps; note that
1664 + # timestamps may already be racy now (depending on previous tests)
1665 + git status &&
1666 + test_set_magic_mtime .git/index &&
1667 + git status &&
1668 + ! test_is_magic_mtime .git/index
1669 +'
1670 +
1671 +test_expect_success 'racy timestamps will be fixed for dirty worktree' '
1672 + echo content2 >racy-dirty &&
1673 + git status &&
1674 + test_set_magic_mtime .git/index &&
1675 + git status &&
1676 + ! test_is_magic_mtime .git/index
1677 +'
1678 +
1679 test_done