Merge branch 'hn/ref-api-tests-update'
[git/debian.git] / t / t1091-sparse-checkout-builtin.sh
blob32a6328ddb69f5ea75389fbab73adc681c76c724
1 #!/bin/sh
3 test_description='sparse checkout builtin tests'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 . ./test-lib.sh
10 list_files() {
11 # Do not replace this with 'ls "$1"', as "ls" with BSD-lineage
12 # enables "-A" by default for root and ends up including ".git" and
13 # such in its output. (Note, though, that running the test suite as
14 # root is generally not recommended.)
15 (cd "$1" && printf '%s\n' *)
18 check_files() {
19 list_files "$1" >actual &&
20 shift &&
21 printf "%s\n" $@ >expect &&
22 test_cmp expect actual
25 test_expect_success 'setup' '
26 git init repo &&
28 cd repo &&
29 echo "initial" >a &&
30 mkdir folder1 folder2 deep &&
31 mkdir deep/deeper1 deep/deeper2 &&
32 mkdir deep/deeper1/deepest &&
33 cp a folder1 &&
34 cp a folder2 &&
35 cp a deep &&
36 cp a deep/deeper1 &&
37 cp a deep/deeper2 &&
38 cp a deep/deeper1/deepest &&
39 git add . &&
40 git commit -m "initial commit"
44 test_expect_success 'git sparse-checkout list (not sparse)' '
45 test_must_fail git -C repo sparse-checkout list >list 2>err &&
46 test_must_be_empty list &&
47 test_i18ngrep "this worktree is not sparse" err
50 test_expect_success 'git sparse-checkout list (not sparse)' '
51 git -C repo sparse-checkout set &&
52 rm repo/.git/info/sparse-checkout &&
53 git -C repo sparse-checkout list >list 2>err &&
54 test_must_be_empty list &&
55 test_i18ngrep "this worktree is not sparse (sparse-checkout file may not exist)" err
58 test_expect_success 'git sparse-checkout list (populated)' '
59 test_when_finished rm -f repo/.git/info/sparse-checkout &&
60 cat >repo/.git/info/sparse-checkout <<-\EOF &&
61 /folder1/*
62 /deep/
63 **/a
64 !*bin*
65 EOF
66 cp repo/.git/info/sparse-checkout expect &&
67 git -C repo sparse-checkout list >list &&
68 test_cmp expect list
71 test_expect_success 'git sparse-checkout init' '
72 git -C repo sparse-checkout init &&
73 cat >expect <<-\EOF &&
75 !/*/
76 EOF
77 test_cmp expect repo/.git/info/sparse-checkout &&
78 test_cmp_config -C repo true core.sparsecheckout &&
79 check_files repo a
82 test_expect_success 'git sparse-checkout list after init' '
83 git -C repo sparse-checkout list >actual &&
84 cat >expect <<-\EOF &&
86 !/*/
87 EOF
88 test_cmp expect actual
91 test_expect_success 'init with existing sparse-checkout' '
92 echo "*folder*" >> repo/.git/info/sparse-checkout &&
93 git -C repo sparse-checkout init &&
94 cat >expect <<-\EOF &&
96 !/*/
97 *folder*
98 EOF
99 test_cmp expect repo/.git/info/sparse-checkout &&
100 check_files repo a folder1 folder2
103 test_expect_success 'clone --sparse' '
104 git clone --sparse "file://$(pwd)/repo" clone &&
105 git -C clone sparse-checkout list >actual &&
106 cat >expect <<-\EOF &&
108 !/*/
110 test_cmp expect actual &&
111 check_files clone a
114 test_expect_success 'switching to cone mode with non-cone mode patterns' '
115 git init bad-patterns &&
117 cd bad-patterns &&
118 git sparse-checkout init &&
119 git sparse-checkout add dir &&
120 git config core.sparseCheckoutCone true &&
121 test_must_fail git sparse-checkout add dir 2>err &&
122 grep "existing sparse-checkout patterns do not use cone mode" err
126 test_expect_success 'interaction with clone --no-checkout (unborn index)' '
127 git clone --no-checkout "file://$(pwd)/repo" clone_no_checkout &&
128 git -C clone_no_checkout sparse-checkout init --cone &&
129 git -C clone_no_checkout sparse-checkout set folder1 &&
131 git -C clone_no_checkout sparse-checkout list >actual &&
132 cat >expect <<-\EOF &&
133 folder1
135 test_cmp expect actual &&
137 # nothing checked out, expect "No such file or directory"
138 ! ls clone_no_checkout/* >actual &&
139 test_must_be_empty actual &&
140 test_path_is_missing clone_no_checkout/.git/index &&
142 # No branch is checked out until we manually switch to one
143 git -C clone_no_checkout switch main &&
144 test_path_is_file clone_no_checkout/.git/index &&
145 check_files clone_no_checkout a folder1
148 test_expect_success 'set enables config' '
149 git init empty-config &&
151 cd empty-config &&
152 test_commit test file &&
153 test_path_is_missing .git/config.worktree &&
154 git sparse-checkout set nothing &&
155 test_path_is_file .git/config.worktree &&
156 test_cmp_config true core.sparseCheckout
160 test_expect_success 'set sparse-checkout using builtin' '
161 git -C repo sparse-checkout set "/*" "!/*/" "*folder*" &&
162 cat >expect <<-\EOF &&
164 !/*/
165 *folder*
167 git -C repo sparse-checkout list >actual &&
168 test_cmp expect actual &&
169 test_cmp expect repo/.git/info/sparse-checkout &&
170 check_files repo a folder1 folder2
173 test_expect_success 'set sparse-checkout using --stdin' '
174 cat >expect <<-\EOF &&
176 !/*/
177 /folder1/
178 /folder2/
180 git -C repo sparse-checkout set --stdin <expect &&
181 git -C repo sparse-checkout list >actual &&
182 test_cmp expect actual &&
183 test_cmp expect repo/.git/info/sparse-checkout &&
184 check_files repo "a folder1 folder2"
187 test_expect_success 'add to sparse-checkout' '
188 cat repo/.git/info/sparse-checkout >old &&
189 test_when_finished cp old repo/.git/info/sparse-checkout &&
190 cat >add <<-\EOF &&
191 pattern1
192 /folder1/
193 pattern2
195 cat old >expect &&
196 cat add >>expect &&
197 git -C repo sparse-checkout add --stdin <add &&
198 git -C repo sparse-checkout list >actual &&
199 test_cmp expect actual &&
200 test_cmp expect repo/.git/info/sparse-checkout &&
201 check_files repo "a folder1 folder2"
204 test_expect_success 'cone mode: match patterns' '
205 git -C repo config --worktree core.sparseCheckoutCone true &&
206 rm -rf repo/a repo/folder1 repo/folder2 &&
207 git -C repo read-tree -mu HEAD 2>err &&
208 test_i18ngrep ! "disabling cone patterns" err &&
209 git -C repo reset --hard &&
210 check_files repo a folder1 folder2
213 test_expect_success 'cone mode: warn on bad pattern' '
214 test_when_finished mv sparse-checkout repo/.git/info/ &&
215 cp repo/.git/info/sparse-checkout . &&
216 echo "!/deep/deeper/*" >>repo/.git/info/sparse-checkout &&
217 git -C repo read-tree -mu HEAD 2>err &&
218 test_i18ngrep "unrecognized negative pattern" err
221 test_expect_success 'sparse-checkout disable' '
222 test_when_finished rm -rf repo/.git/info/sparse-checkout &&
223 git -C repo sparse-checkout disable &&
224 test_path_is_file repo/.git/info/sparse-checkout &&
225 git -C repo config --list >config &&
226 test_must_fail git config core.sparseCheckout &&
227 check_files repo a deep folder1 folder2
230 test_expect_success 'sparse-index enabled and disabled' '
232 sane_unset GIT_TEST_SPLIT_INDEX &&
233 git -C repo update-index --no-split-index &&
235 git -C repo sparse-checkout init --cone --sparse-index &&
236 test_cmp_config -C repo true index.sparse &&
237 test-tool -C repo read-cache --table >cache &&
238 grep " tree " cache &&
240 git -C repo sparse-checkout disable &&
241 test-tool -C repo read-cache --table >cache &&
242 ! grep " tree " cache &&
243 git -C repo config --list >config &&
244 ! grep index.sparse config
248 test_expect_success 'cone mode: init and set' '
249 git -C repo sparse-checkout init --cone &&
250 git -C repo config --list >config &&
251 test_i18ngrep "core.sparsecheckoutcone=true" config &&
252 list_files repo >dir &&
253 echo a >expect &&
254 test_cmp expect dir &&
255 git -C repo sparse-checkout set deep/deeper1/deepest/ 2>err &&
256 test_must_be_empty err &&
257 check_files repo a deep &&
258 check_files repo/deep a deeper1 &&
259 check_files repo/deep/deeper1 a deepest &&
260 cat >expect <<-\EOF &&
262 !/*/
263 /deep/
264 !/deep/*/
265 /deep/deeper1/
266 !/deep/deeper1/*/
267 /deep/deeper1/deepest/
269 test_cmp expect repo/.git/info/sparse-checkout &&
270 git -C repo sparse-checkout set --stdin 2>err <<-\EOF &&
271 folder1
272 folder2
274 test_must_be_empty err &&
275 check_files repo a folder1 folder2
278 test_expect_success 'cone mode: list' '
279 cat >expect <<-\EOF &&
280 folder1
281 folder2
283 git -C repo sparse-checkout set --stdin <expect &&
284 git -C repo sparse-checkout list >actual 2>err &&
285 test_must_be_empty err &&
286 test_cmp expect actual
289 test_expect_success 'cone mode: set with nested folders' '
290 git -C repo sparse-checkout set deep deep/deeper1/deepest 2>err &&
291 test_line_count = 0 err &&
292 cat >expect <<-\EOF &&
294 !/*/
295 /deep/
297 test_cmp repo/.git/info/sparse-checkout expect
300 test_expect_success 'cone mode: add independent path' '
301 git -C repo sparse-checkout set deep/deeper1 &&
302 git -C repo sparse-checkout add folder1 &&
303 cat >expect <<-\EOF &&
305 !/*/
306 /deep/
307 !/deep/*/
308 /deep/deeper1/
309 /folder1/
311 test_cmp expect repo/.git/info/sparse-checkout &&
312 check_files repo a deep folder1
315 test_expect_success 'cone mode: add sibling path' '
316 git -C repo sparse-checkout set deep/deeper1 &&
317 git -C repo sparse-checkout add deep/deeper2 &&
318 cat >expect <<-\EOF &&
320 !/*/
321 /deep/
322 !/deep/*/
323 /deep/deeper1/
324 /deep/deeper2/
326 test_cmp expect repo/.git/info/sparse-checkout &&
327 check_files repo a deep
330 test_expect_success 'cone mode: add parent path' '
331 git -C repo sparse-checkout set deep/deeper1 folder1 &&
332 git -C repo sparse-checkout add deep &&
333 cat >expect <<-\EOF &&
335 !/*/
336 /deep/
337 /folder1/
339 test_cmp expect repo/.git/info/sparse-checkout &&
340 check_files repo a deep folder1
343 test_expect_success 'not-up-to-date does not block rest of sparsification' '
344 test_when_finished git -C repo sparse-checkout disable &&
345 test_when_finished git -C repo reset --hard &&
346 git -C repo sparse-checkout set deep &&
348 echo update >repo/deep/deeper2/a &&
349 cp repo/.git/info/sparse-checkout expect &&
350 test_write_lines "!/deep/*/" "/deep/deeper1/" >>expect &&
352 git -C repo sparse-checkout set deep/deeper1 2>err &&
354 test_i18ngrep "The following paths are not up to date" err &&
355 test_cmp expect repo/.git/info/sparse-checkout &&
356 check_files repo/deep a deeper1 deeper2 &&
357 check_files repo/deep/deeper1 a deepest &&
358 check_files repo/deep/deeper1/deepest a &&
359 check_files repo/deep/deeper2 a
362 test_expect_success 'revert to old sparse-checkout on empty update' '
363 git init empty-test &&
365 echo >file &&
366 git add file &&
367 git commit -m "test" &&
368 git sparse-checkout set nothing 2>err &&
369 test_i18ngrep ! "Sparse checkout leaves no entry on working directory" err &&
370 test_i18ngrep ! ".git/index.lock" err &&
371 git sparse-checkout set file
375 test_expect_success 'fail when lock is taken' '
376 test_when_finished rm -rf repo/.git/info/sparse-checkout.lock &&
377 touch repo/.git/info/sparse-checkout.lock &&
378 test_must_fail git -C repo sparse-checkout set deep 2>err &&
379 test_i18ngrep "Unable to create .*\.lock" err
382 test_expect_success '.gitignore should not warn about cone mode' '
383 git -C repo config --worktree core.sparseCheckoutCone true &&
384 echo "**/bin/*" >repo/.gitignore &&
385 git -C repo reset --hard 2>err &&
386 test_i18ngrep ! "disabling cone patterns" err
389 test_expect_success 'sparse-checkout (init|set|disable) warns with dirty status' '
390 git clone repo dirty &&
391 echo dirty >dirty/folder1/a &&
393 git -C dirty sparse-checkout init 2>err &&
394 test_i18ngrep "warning.*The following paths are not up to date" err &&
396 git -C dirty sparse-checkout set /folder2/* /deep/deeper1/* 2>err &&
397 test_i18ngrep "warning.*The following paths are not up to date" err &&
398 test_path_is_file dirty/folder1/a &&
400 git -C dirty sparse-checkout disable 2>err &&
401 test_must_be_empty err &&
403 git -C dirty reset --hard &&
404 git -C dirty sparse-checkout init &&
405 git -C dirty sparse-checkout set /folder2/* /deep/deeper1/* &&
406 test_path_is_missing dirty/folder1/a &&
407 git -C dirty sparse-checkout disable &&
408 test_path_is_file dirty/folder1/a
411 test_expect_success 'sparse-checkout (init|set|disable) warns with unmerged status' '
412 git clone repo unmerged &&
414 cat >input <<-EOF &&
415 0 $ZERO_OID folder1/a
416 100644 $(git -C unmerged rev-parse HEAD:folder1/a) 1 folder1/a
418 git -C unmerged update-index --index-info <input &&
420 git -C unmerged sparse-checkout init 2>err &&
421 test_i18ngrep "warning.*The following paths are unmerged" err &&
423 git -C unmerged sparse-checkout set /folder2/* /deep/deeper1/* 2>err &&
424 test_i18ngrep "warning.*The following paths are unmerged" err &&
425 test_path_is_file dirty/folder1/a &&
427 git -C unmerged sparse-checkout disable 2>err &&
428 test_i18ngrep "warning.*The following paths are unmerged" err &&
430 git -C unmerged reset --hard &&
431 git -C unmerged sparse-checkout init &&
432 git -C unmerged sparse-checkout set /folder2/* /deep/deeper1/* &&
433 git -C unmerged sparse-checkout disable
436 test_expect_failure 'sparse-checkout reapply' '
437 git clone repo tweak &&
439 echo dirty >tweak/deep/deeper2/a &&
441 cat >input <<-EOF &&
442 0 $ZERO_OID folder1/a
443 100644 $(git -C tweak rev-parse HEAD:folder1/a) 1 folder1/a
445 git -C tweak update-index --index-info <input &&
447 git -C tweak sparse-checkout init --cone 2>err &&
448 test_i18ngrep "warning.*The following paths are not up to date" err &&
449 test_i18ngrep "warning.*The following paths are unmerged" err &&
451 git -C tweak sparse-checkout set folder2 deep/deeper1 2>err &&
452 test_i18ngrep "warning.*The following paths are not up to date" err &&
453 test_i18ngrep "warning.*The following paths are unmerged" err &&
455 git -C tweak sparse-checkout reapply 2>err &&
456 test_i18ngrep "warning.*The following paths are not up to date" err &&
457 test_path_is_file tweak/deep/deeper2/a &&
458 test_i18ngrep "warning.*The following paths are unmerged" err &&
459 test_path_is_file tweak/folder1/a &&
461 git -C tweak checkout HEAD deep/deeper2/a &&
462 git -C tweak sparse-checkout reapply 2>err &&
463 test_i18ngrep ! "warning.*The following paths are not up to date" err &&
464 test_path_is_missing tweak/deep/deeper2/a &&
465 test_i18ngrep "warning.*The following paths are unmerged" err &&
466 test_path_is_file tweak/folder1/a &&
468 # NEEDSWORK: We are asking to update a file outside of the
469 # sparse-checkout cone, but this is no longer allowed.
470 git -C tweak add folder1/a &&
471 git -C tweak sparse-checkout reapply 2>err &&
472 test_must_be_empty err &&
473 test_path_is_missing tweak/deep/deeper2/a &&
474 test_path_is_missing tweak/folder1/a &&
476 git -C tweak sparse-checkout disable
479 test_expect_success 'cone mode: set with core.ignoreCase=true' '
480 rm repo/.git/info/sparse-checkout &&
481 git -C repo sparse-checkout init --cone &&
482 git -C repo -c core.ignoreCase=true sparse-checkout set folder1 &&
483 cat >expect <<-\EOF &&
485 !/*/
486 /folder1/
488 test_cmp expect repo/.git/info/sparse-checkout &&
489 check_files repo a folder1
492 test_expect_success 'interaction with submodules' '
493 git clone repo super &&
495 cd super &&
496 mkdir modules &&
497 git submodule add ../repo modules/child &&
498 git add . &&
499 git commit -m "add submodule" &&
500 git sparse-checkout init --cone &&
501 git sparse-checkout set folder1
502 ) &&
503 check_files super a folder1 modules &&
504 check_files super/modules/child a deep folder1 folder2
507 test_expect_success 'different sparse-checkouts with worktrees' '
508 git -C repo worktree add --detach ../worktree &&
509 check_files worktree "a deep folder1 folder2" &&
510 git -C worktree sparse-checkout init --cone &&
511 git -C repo sparse-checkout set folder1 &&
512 git -C worktree sparse-checkout set deep/deeper1 &&
513 check_files repo a folder1 &&
514 check_files worktree a deep
517 test_expect_success 'set using filename keeps file on-disk' '
518 git -C repo sparse-checkout set a deep &&
519 cat >expect <<-\EOF &&
521 !/*/
523 /deep/
525 test_cmp expect repo/.git/info/sparse-checkout &&
526 check_files repo a deep
529 check_read_tree_errors () {
530 REPO=$1
531 FILES=$2
532 ERRORS=$3
533 git -C $REPO -c core.sparseCheckoutCone=false read-tree -mu HEAD 2>err &&
534 test_must_be_empty err &&
535 check_files $REPO "$FILES" &&
536 git -C $REPO read-tree -mu HEAD 2>err &&
537 if test -z "$ERRORS"
538 then
539 test_must_be_empty err
540 else
541 test_i18ngrep "$ERRORS" err
542 fi &&
543 check_files $REPO $FILES
546 test_expect_success 'pattern-checks: /A/**' '
547 cat >repo/.git/info/sparse-checkout <<-\EOF &&
549 !/*/
550 /folder1/**
552 check_read_tree_errors repo "a folder1" "disabling cone pattern matching"
555 test_expect_success 'pattern-checks: /A/**/B/' '
556 cat >repo/.git/info/sparse-checkout <<-\EOF &&
558 !/*/
559 /deep/**/deepest
561 check_read_tree_errors repo "a deep" "disabling cone pattern matching" &&
562 check_files repo/deep "deeper1" &&
563 check_files repo/deep/deeper1 "deepest"
566 test_expect_success 'pattern-checks: too short' '
567 cat >repo/.git/info/sparse-checkout <<-\EOF &&
569 !/*/
572 check_read_tree_errors repo "a" "disabling cone pattern matching"
574 test_expect_success 'pattern-checks: not too short' '
575 cat >repo/.git/info/sparse-checkout <<-\EOF &&
577 !/*/
580 git -C repo read-tree -mu HEAD 2>err &&
581 test_must_be_empty err &&
582 check_files repo a
585 test_expect_success 'pattern-checks: trailing "*"' '
586 cat >repo/.git/info/sparse-checkout <<-\EOF &&
588 !/*/
591 check_read_tree_errors repo "a" "disabling cone pattern matching"
594 test_expect_success 'pattern-checks: starting "*"' '
595 cat >repo/.git/info/sparse-checkout <<-\EOF &&
597 !/*/
598 *eep/
600 check_read_tree_errors repo "a deep" "disabling cone pattern matching"
603 test_expect_success 'pattern-checks: contained glob characters' '
604 for c in "[a]" "\\" "?" "*"
606 cat >repo/.git/info/sparse-checkout <<-EOF &&
608 !/*/
609 something$c-else/
611 check_read_tree_errors repo "a" "disabling cone pattern matching" || return 1
612 done
615 test_expect_success BSLASHPSPEC 'pattern-checks: escaped characters' '
616 git clone repo escaped &&
617 TREEOID=$(git -C escaped rev-parse HEAD:folder1) &&
618 NEWTREE=$(git -C escaped mktree <<-EOF
619 $(git -C escaped ls-tree HEAD)
620 040000 tree $TREEOID zbad\\dir
621 040000 tree $TREEOID zdoes*exist
622 040000 tree $TREEOID zglob[!a]?
624 ) &&
625 COMMIT=$(git -C escaped commit-tree $NEWTREE -p HEAD) &&
626 git -C escaped reset --hard $COMMIT &&
627 check_files escaped "a deep folder1 folder2 zbad\\dir zdoes*exist" zglob[!a]? &&
628 git -C escaped sparse-checkout init --cone &&
629 git -C escaped sparse-checkout set zbad\\dir/bogus "zdoes*not*exist" "zdoes*exist" "zglob[!a]?" &&
630 cat >expect <<-\EOF &&
632 !/*/
633 /zbad\\dir/
634 !/zbad\\dir/*/
635 /zbad\\dir/bogus/
636 /zdoes\*exist/
637 /zdoes\*not\*exist/
638 /zglob\[!a]\?/
640 test_cmp expect escaped/.git/info/sparse-checkout &&
641 check_read_tree_errors escaped "a zbad\\dir zdoes*exist zglob[!a]?" &&
642 git -C escaped ls-tree -d --name-only HEAD >list-expect &&
643 git -C escaped sparse-checkout set --stdin <list-expect &&
644 cat >expect <<-\EOF &&
646 !/*/
647 /deep/
648 /folder1/
649 /folder2/
650 /zbad\\dir/
651 /zdoes\*exist/
652 /zglob\[!a]\?/
654 test_cmp expect escaped/.git/info/sparse-checkout &&
655 check_files escaped "a deep folder1 folder2 zbad\\dir zdoes*exist" zglob[!a]? &&
656 git -C escaped sparse-checkout list >list-actual &&
657 test_cmp list-expect list-actual
660 test_expect_success MINGW 'cone mode replaces backslashes with slashes' '
661 git -C repo sparse-checkout set deep\\deeper1 &&
662 cat >expect <<-\EOF &&
664 !/*/
665 /deep/
666 !/deep/*/
667 /deep/deeper1/
669 test_cmp expect repo/.git/info/sparse-checkout &&
670 check_files repo a deep &&
671 check_files repo/deep a deeper1
674 test_expect_success 'cone mode clears ignored subdirectories' '
675 rm repo/.git/info/sparse-checkout &&
677 git -C repo sparse-checkout init --cone &&
678 git -C repo sparse-checkout set deep/deeper1 &&
680 cat >repo/.gitignore <<-\EOF &&
681 obj/
685 git -C repo add .gitignore &&
686 git -C repo commit -m ".gitignore" &&
688 mkdir -p repo/obj repo/folder1/obj repo/deep/deeper2/obj &&
689 for file in folder1/obj/a obj/a folder1/file.o folder1.o \
690 deep/deeper2/obj/a deep/deeper2/file.o file.o
692 echo ignored >repo/$file || return 1
693 done &&
695 git -C repo status --porcelain=v2 >out &&
696 test_must_be_empty out &&
698 git -C repo sparse-checkout reapply &&
699 test_path_is_missing repo/folder1 &&
700 test_path_is_missing repo/deep/deeper2 &&
701 test_path_is_dir repo/obj &&
702 test_path_is_file repo/file.o &&
704 git -C repo status --porcelain=v2 >out &&
705 test_must_be_empty out &&
707 git -C repo sparse-checkout set deep/deeper2 &&
708 test_path_is_missing repo/deep/deeper1 &&
709 test_path_is_dir repo/deep/deeper2 &&
710 test_path_is_dir repo/obj &&
711 test_path_is_file repo/file.o &&
713 >repo/deep/deeper2/ignored.o &&
714 >repo/deep/deeper2/untracked &&
716 # When an untracked file is in the way, all untracked files
717 # (even ignored files) are preserved.
718 git -C repo sparse-checkout set folder1 2>err &&
719 grep "contains untracked files" err &&
720 test_path_is_file repo/deep/deeper2/ignored.o &&
721 test_path_is_file repo/deep/deeper2/untracked &&
723 # The rest of the cone matches expectation
724 test_path_is_missing repo/deep/deeper1 &&
725 test_path_is_dir repo/obj &&
726 test_path_is_file repo/file.o &&
728 git -C repo status --porcelain=v2 >out &&
729 echo "? deep/deeper2/untracked" >expect &&
730 test_cmp expect out
733 test_expect_success 'malformed cone-mode patterns' '
734 git -C repo sparse-checkout init --cone &&
735 mkdir -p repo/foo/bar &&
736 touch repo/foo/bar/x repo/foo/y &&
737 cat >repo/.git/info/sparse-checkout <<-\EOF &&
739 !/*/
740 /foo/
741 !/foo/*/
742 /foo/\*/
745 # Listing the patterns will notice the duplicate pattern and
746 # emit a warning. It will list the patterns directly instead
747 # of using the cone-mode translation to a set of directories.
748 git -C repo sparse-checkout list >actual 2>err &&
749 test_cmp repo/.git/info/sparse-checkout actual &&
750 grep "warning: your sparse-checkout file may have issues: pattern .* is repeated" err &&
751 grep "warning: disabling cone pattern matching" err
754 test_done