Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerrick Stolee <derrickstolee@github.com>2022-05-23 16:48:37 +0300
committerJunio C Hamano <gitster@pobox.com>2022-05-23 21:08:20 +0300
commitbaa73e2b75645a088268266a408f502457663876 (patch)
tree295365ed147e88293917f6e82464e0f17ca1b85c /t/t1092-sparse-checkout-compatibility.sh
parente54793a95afeea1e10de1e5ad7eab914e7416250 (diff)
t1092: refactor 'sparse-index contents' test
Before expanding this test with more involved cases, first extract the repeated logic into a new test_sparse_checkout_set helper. This helper checks that 'git sparse-checkout set ...' succeeds and then verifies that certain directories have sparse directory entries in the sparse index. It also verifies that the in-cone directories are _not_ sparse directory entries in the sparse index. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1092-sparse-checkout-compatibility.sh')
-rwxr-xr-xt/t1092-sparse-checkout-compatibility.sh53
1 files changed, 35 insertions, 18 deletions
diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh
index 236ab53028..9355e75a5d 100755
--- a/t/t1092-sparse-checkout-compatibility.sh
+++ b/t/t1092-sparse-checkout-compatibility.sh
@@ -205,36 +205,53 @@ test_sparse_unstaged () {
done
}
-test_expect_success 'sparse-index contents' '
- init_repos &&
-
+# Usage: test_sprase_checkout_set "<c1> ... <cN>" "<s1> ... <sM>"
+# Verifies that "git sparse-checkout set <c1> ... <cN>" succeeds and
+# leaves the sparse index in a state where <s1> ... <sM> are sparse
+# directories (and <c1> ... <cN> are not).
+test_sparse_checkout_set () {
+ CONE_DIRS=$1 &&
+ SPARSE_DIRS=$2 &&
+ git -C sparse-index sparse-checkout set $CONE_DIRS &&
git -C sparse-index ls-files --sparse --stage >cache &&
- for dir in folder1 folder2 x
+
+ # Check that the directories outside of the sparse-checkout cone
+ # have sparse directory entries.
+ for dir in $SPARSE_DIRS
do
TREE=$(git -C sparse-index rev-parse HEAD:$dir) &&
grep "040000 $TREE 0 $dir/" cache \
|| return 1
done &&
- git -C sparse-index sparse-checkout set folder1 &&
-
- git -C sparse-index ls-files --sparse --stage >cache &&
- for dir in deep folder2 x
+ # Check that the directories in the sparse-checkout cone
+ # are not sparse directory entries.
+ for dir in $CONE_DIRS
do
TREE=$(git -C sparse-index rev-parse HEAD:$dir) &&
- grep "040000 $TREE 0 $dir/" cache \
+ ! grep "040000 $TREE 0 $dir/" cache \
|| return 1
- done &&
+ done
+}
- git -C sparse-index sparse-checkout set deep/deeper1 &&
+test_expect_success 'sparse-index contents' '
+ init_repos &&
- git -C sparse-index ls-files --sparse --stage >cache &&
- for dir in deep/deeper2 folder1 folder2 x
- do
- TREE=$(git -C sparse-index rev-parse HEAD:$dir) &&
- grep "040000 $TREE 0 $dir/" cache \
- || return 1
- done &&
+ # Remove deep, add three other directories.
+ test_sparse_checkout_set \
+ "folder1 folder2 x" \
+ "before deep" &&
+
+ # Remove folder1, add deep
+ test_sparse_checkout_set \
+ "deep folder2 x" \
+ "before folder1" &&
+
+ # Replace deep with deep/deeper2 (dropping deep/deeper1)
+ # Add folder1
+ test_sparse_checkout_set \
+ "deep/deeper2 folder1 folder2 x" \
+ "before deep/deeper1" &&
# Disabling the sparse-index replaces tree entries with full ones
git -C sparse-index sparse-checkout init --no-sparse-index &&