t1092: replace 'read-cache --table' with 'ls-files --sparse'
Now that 'git ls-files --sparse' exists, we can use it to verify the state of a sparse index instead of 'test-tool read-cache table'. Replace these usages within t1092-sparse-checkout-compatibility.sh. The important changes are due to the different output format. We need to use the '--stage' output to get a file mode and OID, but it also includes a stage value and drops the object type. This leads to some differences in how we handle looking for specific entries. Some places where we previously looked for no 'tree' entries, we can instead directly compare the output across the repository with a sparse index and the one without. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
78087097b8
commit
3a9a6ac5d9
|
@ -206,45 +206,42 @@ test_sparse_unstaged () {
|
||||||
test_expect_success 'sparse-index contents' '
|
test_expect_success 'sparse-index contents' '
|
||||||
init_repos &&
|
init_repos &&
|
||||||
|
|
||||||
test-tool -C sparse-index read-cache --table >cache &&
|
git -C sparse-index ls-files --sparse --stage >cache &&
|
||||||
for dir in folder1 folder2 x
|
for dir in folder1 folder2 x
|
||||||
do
|
do
|
||||||
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 0 $dir/" cache \
|
||||||
|| return 1
|
|| return 1
|
||||||
done &&
|
done &&
|
||||||
|
|
||||||
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 &&
|
git -C sparse-index ls-files --sparse --stage >cache &&
|
||||||
for dir in deep folder2 x
|
for dir in deep folder2 x
|
||||||
do
|
do
|
||||||
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 0 $dir/" cache \
|
||||||
|| return 1
|
|| return 1
|
||||||
done &&
|
done &&
|
||||||
|
|
||||||
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 &&
|
git -C sparse-index ls-files --sparse --stage >cache &&
|
||||||
for dir in deep/deeper2 folder1 folder2 x
|
for dir in deep/deeper2 folder1 folder2 x
|
||||||
do
|
do
|
||||||
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 0 $dir/" cache \
|
||||||
|| return 1
|
|| return 1
|
||||||
done &&
|
done &&
|
||||||
|
|
||||||
# Disabling the sparse-index removes tree entries with full ones
|
# Disabling the sparse-index replaces tree entries with full ones
|
||||||
git -C sparse-index sparse-checkout init --no-sparse-index &&
|
git -C sparse-index sparse-checkout init --no-sparse-index &&
|
||||||
|
test_sparse_match git ls-files --stage --sparse
|
||||||
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' '
|
||||||
init_repos &&
|
init_repos &&
|
||||||
test_sparse_match test-tool read-cache --expand --table
|
test_sparse_match git ls-files --stage
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'status with options' '
|
test_expect_success 'status with options' '
|
||||||
|
@ -801,9 +798,9 @@ test_expect_success 'submodule handling' '
|
||||||
|
|
||||||
# having a submodule prevents "modules" from collapse
|
# having a submodule prevents "modules" from collapse
|
||||||
test_sparse_match git sparse-checkout set deep/deeper1 &&
|
test_sparse_match git sparse-checkout set deep/deeper1 &&
|
||||||
test-tool -C sparse-index read-cache --table >cache &&
|
git -C sparse-index ls-files --sparse --stage >cache &&
|
||||||
grep "100644 blob .* modules/a" cache &&
|
grep "100644 .* modules/a" cache &&
|
||||||
grep "160000 commit $(git -C initial-repo rev-parse HEAD) modules/sub" cache
|
grep "160000 $(git -C initial-repo rev-parse HEAD) 0 modules/sub" cache
|
||||||
'
|
'
|
||||||
|
|
||||||
# When working with a sparse index, some commands will need to expand the
|
# When working with a sparse index, some commands will need to expand the
|
||||||
|
@ -1125,13 +1122,13 @@ test_expect_success 'reset mixed and checkout orphan' '
|
||||||
# the sparse checkouts skip "adding" the other side of
|
# the sparse checkouts skip "adding" the other side of
|
||||||
# the conflict.
|
# the conflict.
|
||||||
test_sparse_match git reset --mixed HEAD~1 &&
|
test_sparse_match git reset --mixed HEAD~1 &&
|
||||||
test_sparse_match test-tool read-cache --table --expand &&
|
test_sparse_match git ls-files --stage &&
|
||||||
test_sparse_match git status --porcelain=v2 &&
|
test_sparse_match git status --porcelain=v2 &&
|
||||||
|
|
||||||
# At this point, sparse-checkouts behave differently
|
# At this point, sparse-checkouts behave differently
|
||||||
# from the full-checkout.
|
# from the full-checkout.
|
||||||
test_sparse_match git checkout --orphan new-branch &&
|
test_sparse_match git checkout --orphan new-branch &&
|
||||||
test_sparse_match test-tool read-cache --table --expand &&
|
test_sparse_match git ls-files --stage &&
|
||||||
test_sparse_match git status --porcelain=v2
|
test_sparse_match git status --porcelain=v2
|
||||||
'
|
'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue