summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Derrick Stolee <dstolee@microsoft.com>2020-01-31 20:16:10 +0000
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-01-31 13:05:29 -0800
commitd585f0e7992ea7f025a5a91f46f2baa9e88f19f6 (patch)
treed311a04ddf853f4784a28e590c6eeb76c9dd91c5 /t
parentsparse-checkout: properly match escaped characters (diff)
downloadtgif-d585f0e7992ea7f025a5a91f46f2baa9e88f19f6.tar.xz
sparse-checkout: write escaped patterns in cone mode
If a user somehow creates a directory with an asterisk (*) or backslash (\), then the "git sparse-checkout set" command will struggle to provide the correct pattern in the sparse-checkout file. When not in cone mode, the provided pattern is written directly into the sparse-checkout file. However, in cone mode we expect a list of paths to directories and then we convert those into patterns. However, there is some care needed for the timing of these escapes. The in-memory pattern list is used to update the working directory before writing the patterns to disk. Thus, we need the command to have the unescaped names in the hashsets for the cone comparisons, then escape the patterns later. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t1091-sparse-checkout-builtin.sh10
1 files changed, 8 insertions, 2 deletions
diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh
index 9ea700896d..fb8718e64a 100755
--- a/t/t1091-sparse-checkout-builtin.sh
+++ b/t/t1091-sparse-checkout-builtin.sh
@@ -309,6 +309,9 @@ check_read_tree_errors () {
REPO=$1
FILES=$2
ERRORS=$3
+ git -C $REPO -c core.sparseCheckoutCone=false read-tree -mu HEAD 2>err &&
+ test_must_be_empty err &&
+ check_files $REPO "$FILES" &&
git -C $REPO read-tree -mu HEAD 2>err &&
if test -z "$ERRORS"
then
@@ -391,14 +394,17 @@ test_expect_success BSLASHPSPEC 'pattern-checks: escaped "*"' '
git -C escaped reset --hard $COMMIT &&
check_files escaped "a deep folder1 folder2 zbad\\dir zdoes*exist" &&
git -C escaped sparse-checkout init --cone &&
- cat >escaped/.git/info/sparse-checkout <<-\EOF &&
+ git -C escaped sparse-checkout set zbad\\dir/bogus "zdoes*not*exist" "zdoes*exist" &&
+ cat >expect <<-\EOF &&
/*
!/*/
/zbad\\dir/
!/zbad\\dir/*/
- /zdoes\*not\*exist/
+ /zbad\\dir/bogus/
/zdoes\*exist/
+ /zdoes\*not\*exist/
EOF
+ test_cmp expect escaped/.git/info/sparse-checkout &&
check_read_tree_errors escaped "a zbad\\dir zdoes*exist"
'