t1700-split-index: date back files to avoid racy situations
't1700-split-index.sh' checks that the index was split correctly under
various circumstances and that all the different ways to turn the
split index feature on and off work correctly. To do so, most of its
tests use 'test-tool dump-split-index' to see which files have their
cache entries in the split index. All these tests assume that all
cache entries are written to the shared index (called "base"
throughout these tests) when a new shared index is created. This is
an implementation detail: most git commands (basically all except 'git
update-index') don't care or know at all about split index or whether
a cache entry is stored in the split or shared index.
As demonstrated in the previous patch, refreshing a split index is
prone to a variant of the classic racy git issue. The next patch will
fix this issue, but while doing so it will also slightly change this
behaviour: only cache entries with mtime in the past will be written
only to the newly created shared index, but racily clean cache entries
will be written to the new split index (with smudged stat data).
While this upcoming change won't at all affect any git commands, it
will violate the above mentioned assumption of 't1700's tests. Since
these tests create or modify files and create or refresh the split
index in rapid succession, there are plenty of racily clean cache
entries to be dealt with, which will then be written to the new split
indexes, and, ultimately, will cause several tests in 't1700' to fail.
Let's prepare 't1700-split-index.sh' for this upcoming change and
modify its tests to avoid racily clean files by backdating the mtime
of any file modifications (and since a lot of tests create or modify
files, encapsulate it into a helper function).
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
@ -86,7 +93,7 @@ test_expect_success 'enable split index again, "one" now belongs to base index"'
@@ -86,7 +93,7 @@ test_expect_success 'enable split index again, "one" now belongs to base index"'
'
test_expect_success 'modify original file, base index untouched' '
echo modified >one &&
echo modified | create_non_racy_file one &&
git update-index one &&
git ls-files --stage >ls-files.actual &&
cat >ls-files.expect <<-EOF &&
@ -105,7 +112,7 @@ test_expect_success 'modify original file, base index untouched' '
@@ -105,7 +112,7 @@ test_expect_success 'modify original file, base index untouched' '
'
test_expect_success 'add another file, which stays index' '
: >two &&
create_non_racy_file two &&
git update-index --add two &&
git ls-files --stage >ls-files.actual &&
cat >ls-files.expect <<-EOF &&
@ -158,7 +165,7 @@ test_expect_success 'remove file in base index' '
@@ -158,7 +165,7 @@ test_expect_success 'remove file in base index' '
'
test_expect_success 'add original file back' '
: >one &&
create_non_racy_file one &&
git update-index --add one &&
git ls-files --stage >ls-files.actual &&
cat >ls-files.expect <<-EOF &&
@ -177,7 +184,7 @@ test_expect_success 'add original file back' '
@@ -177,7 +184,7 @@ test_expect_success 'add original file back' '
@ -347,12 +354,12 @@ test_expect_success 'shared index files expire after 2 weeks by default' '
@@ -347,12 +354,12 @@ test_expect_success 'shared index files expire after 2 weeks by default' '
test_expect_success 'check splitIndex.sharedIndexExpire set to 16 days' '
@ -361,13 +368,13 @@ test_expect_success 'check splitIndex.sharedIndexExpire set to "never" and "now"
@@ -361,13 +368,13 @@ test_expect_success 'check splitIndex.sharedIndexExpire set to "never" and "now"