@ -6,6 +6,7 @@ test_description='compare full workdir to sparse workdir'
# So, disable the check until that integration is complete.
# So, disable the check until that integration is complete.
GIT_TEST_CHECK_CACHE_TREE=0
GIT_TEST_CHECK_CACHE_TREE=0
GIT_TEST_SPLIT_INDEX=0
GIT_TEST_SPLIT_INDEX=0
GIT_TEST_SPARSE_INDEX=
. ./test-lib.sh
. ./test-lib.sh
@ -100,25 +101,26 @@ init_repos () {
# initialize sparse-checkout definitions
# initialize sparse-checkout definitions
git -C sparse-checkout sparse-checkout init --cone &&
git -C sparse-checkout sparse-checkout init --cone &&
git -C sparse-checkout sparse-checkout set deep &&
git -C sparse-checkout sparse-checkout set deep &&
GIT_TEST_SPARSE_INDEX=1 git -C sparse-index sparse-checkout init --cone &&
git -C sparse-index sparse-checkout init --cone --sparse-index &&
GIT_TEST_SPARSE_INDEX=1 git -C sparse-index sparse-checkout set deep
test_cmp_config -C sparse-index true index.sparse &&
git -C sparse-index sparse-checkout set deep
}
}
run_on_sparse () {
run_on_sparse () {
(
(
cd sparse-checkout &&
cd sparse-checkout &&
GIT_TEST_SPARSE_INDEX=0 "$@" >../sparse-checkout-out 2>../sparse-checkout-err
"$@" >../sparse-checkout-out 2>../sparse-checkout-err
) &&
) &&
(
(
cd sparse-index &&
cd sparse-index &&
GIT_TEST_SPARSE_INDEX=1 "$@" >../sparse-index-out 2>../sparse-index-err
"$@" >../sparse-index-out 2>../sparse-index-err
)
)
}
}
run_on_all () {
run_on_all () {
(
(
cd full-checkout &&
cd full-checkout &&
GIT_TEST_SPARSE_INDEX=0 "$@" >../full-checkout-out 2>../full-checkout-err
"$@" >../full-checkout-out 2>../full-checkout-err
) &&
) &&
run_on_sparse "$@"
run_on_sparse "$@"
}
}
@ -148,7 +150,7 @@ test_expect_success 'sparse-index contents' '
|| return 1
|| return 1
done &&
done &&
GIT_TEST_SPARSE_INDEX=1 git -C sparse-index sparse-checkout set folder1 &&
git -C sparse-index sparse-checkout set folder1 &&
test-tool -C sparse-index read-cache --table >cache &&
test-tool -C sparse-index read-cache --table >cache &&
for dir in deep folder2 x
for dir in deep folder2 x
@ -158,7 +160,7 @@ test_expect_success 'sparse-index contents' '
|| return 1
|| return 1
done &&
done &&
GIT_TEST_SPARSE_INDEX=1 git -C sparse-index sparse-checkout set deep/deeper1 &&
git -C sparse-index sparse-checkout set deep/deeper1 &&
test-tool -C sparse-index read-cache --table >cache &&
test-tool -C sparse-index read-cache --table >cache &&
for dir in deep/deeper2 folder1 folder2 x
for dir in deep/deeper2 folder1 folder2 x
@ -166,7 +168,14 @@ test_expect_success 'sparse-index contents' '
TREE=$(git -C sparse-index rev-parse HEAD:$dir) &&
TREE=$(git -C sparse-index rev-parse HEAD:$dir) &&
grep "040000 tree $TREE $dir/" cache \
grep "040000 tree $TREE $dir/" cache \
|| return 1
|| return 1
done
done &&
# Disabling the sparse-index removes tree entries with full ones
git -C sparse-index sparse-checkout init --no-sparse-index &&
test-tool -C sparse-index read-cache --table >cache &&
! grep "040000 tree" cache &&
test_sparse_match test-tool read-cache --table
'
'
test_expect_success 'expanded in-memory index matches full index' '
test_expect_success 'expanded in-memory index matches full index' '
@ -396,19 +405,15 @@ test_expect_success 'submodule handling' '
test_expect_success 'sparse-index is expanded and converted back' '
test_expect_success 'sparse-index is expanded and converted back' '
init_repos &&
init_repos &&
(
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
GIT_TEST_SPARSE_INDEX=1 &&
git -C sparse-index -c core.fsmonitor="" reset --hard &&
export GIT_TEST_SPARSE_INDEX &&
test_region index convert_to_sparse trace2.txt &&
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
test_region index ensure_full_index trace2.txt &&
git -C sparse-index -c core.fsmonitor="" reset --hard &&
test_region index convert_to_sparse trace2.txt &&
rm trace2.txt &&
test_region index ensure_full_index trace2.txt &&
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
git -C sparse-index -c core.fsmonitor="" status -uno &&
rm trace2.txt &&
test_region index ensure_full_index trace2.txt
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
git -C sparse-index -c core.fsmonitor="" status -uno &&
test_region index ensure_full_index trace2.txt
)
'
'
test_done
test_done