[PATCH v2 1/2] t7508: add tests capturing racy timestamp handling
- From
Marc Strapetz via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Jan 5, 2022, 13:15 UTC
- Message-ID
- <7d58f80611193f8696d99e317fe6b1e53ac740f7.1641388523.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.1105.v2.git.1641388523.gitgitgadget@gmail.com>
From: Marc Strapetz <marc.strapetz@syntevo.com>
"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> --- t/t7508-status.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
diff --git a/t/t7508-status.sh b/t/t7508-status.sh index 05c6c02435d..652cbb5ed2e 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -1656,4 +1656,32 @@ test_expect_success '--no-optional-locks prevents index update' ' ! grep ^1234567890 out ' +test_expect_success 'racy timestamps will be fixed for clean worktree' ' + echo content >racy-dirty && + echo content >racy-racy && + git add racy* && + git commit -m "racy test files" && + # let status rewrite the index, if necessary; after that we expect + # no more index writes unless caused by racy timestamps; note that + # timestamps may already be racy now (depending on previous tests) + git status && + test-tool chmtime =1234567890 .git/index && + test-tool chmtime --get .git/index >out && + grep ^1234567890 out && + git status && + test-tool chmtime --get .git/index >out && + ! grep ^1234567890 out +' + +test_expect_success 'racy timestamps will be fixed for dirty worktree' ' + echo content2 >racy-dirty && + git status && + test-tool chmtime =1234567890 .git/index && + test-tool chmtime --get .git/index >out && + grep ^1234567890 out && + git status && + test-tool chmtime --get .git/index >out && + ! grep ^1234567890 out +' + test_done
-- gitgitgadget