summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Derrick Stolee <dstolee@microsoft.com>2021-09-08 01:42:25 +0000
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-09-07 22:41:09 -0700
commit522d3cec0089228d0b1a5178c396662953cb2dc2 (patch)
tree50626d3df871d4b47a13244e110e3006813d7527 /t
parentMerge branch 'ds/add-with-sparse-index' into ds/sparse-index-ignored-files (diff)
downloadtgif-522d3cec0089228d0b1a5178c396662953cb2dc2.tar.xz
t7519: rewrite sparse index test
The sparse index is tested with the FS Monitor hook and extension since f8fe49e (fsmonitor: integrate with sparse index, 2021-07-14). This test was very fragile because it shared an index across sparse and non-sparse behavior. Since that expansion and contraction could cause the index to lose its FS Monitor bitmap and token, behavior is fragile to changes in 'git sparse-checkout set'. Rewrite the test to use two clones of the original repo: full and sparse. This allows us to also keep the test files (actual, expect, trace2.txt) out of the repos we are testing with 'git status'. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t7519-status-fsmonitor.sh38
1 files changed, 21 insertions, 17 deletions
diff --git a/t/t7519-status-fsmonitor.sh b/t/t7519-status-fsmonitor.sh
index deea88d443..f1463197b9 100755
--- a/t/t7519-status-fsmonitor.sh
+++ b/t/t7519-status-fsmonitor.sh
@@ -389,43 +389,47 @@ test_expect_success 'status succeeds after staging/unstaging' '
# If "!" is supplied, then we verify that we do not call ensure_full_index
# during a call to 'git status'. Otherwise, we verify that we _do_ call it.
check_sparse_index_behavior () {
- git status --porcelain=v2 >expect &&
- git sparse-checkout init --cone --sparse-index &&
- git sparse-checkout set dir1 dir2 &&
+ git -C full status --porcelain=v2 >expect &&
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
- git status --porcelain=v2 >actual &&
+ git -C sparse status --porcelain=v2 >actual &&
test_region $1 index ensure_full_index trace2.txt &&
test_region fsm_hook query trace2.txt &&
test_cmp expect actual &&
- rm trace2.txt &&
- git sparse-checkout disable
+ rm trace2.txt
}
test_expect_success 'status succeeds with sparse index' '
- git reset --hard &&
+ git clone . full &&
+ git clone --sparse . sparse &&
+ git -C sparse sparse-checkout init --cone --sparse-index &&
+ git -C sparse sparse-checkout set dir1 dir2 &&
- test_config core.fsmonitor "$TEST_DIRECTORY/t7519/fsmonitor-all" &&
- check_sparse_index_behavior ! &&
-
- write_script .git/hooks/fsmonitor-test<<-\EOF &&
+ write_script .git/hooks/fsmonitor-test <<-\EOF &&
printf "last_update_token\0"
EOF
- git config core.fsmonitor .git/hooks/fsmonitor-test &&
+ git -C full config core.fsmonitor ../.git/hooks/fsmonitor-test &&
+ git -C sparse config core.fsmonitor ../.git/hooks/fsmonitor-test &&
check_sparse_index_behavior ! &&
- write_script .git/hooks/fsmonitor-test<<-\EOF &&
+ write_script .git/hooks/fsmonitor-test <<-\EOF &&
printf "last_update_token\0"
printf "dir1/modified\0"
EOF
check_sparse_index_behavior ! &&
- cp -r dir1 dir1a &&
- git add dir1a &&
- git commit -m "add dir1a" &&
+ git -C sparse sparse-checkout add dir1a &&
+
+ for repo in full sparse
+ do
+ cp -r $repo/dir1 $repo/dir1a &&
+ git -C $repo add dir1a &&
+ git -C $repo commit -m "add dir1a" || return 1
+ done &&
+ git -C sparse sparse-checkout set dir1 dir2 &&
# This one modifies outside the sparse-checkout definition
# and hence we expect to expand the sparse-index.
- write_script .git/hooks/fsmonitor-test<<-\EOF &&
+ write_script .git/hooks/fsmonitor-test <<-\EOF &&
printf "last_update_token\0"
printf "dir1a/modified\0"
EOF