tree-wide: apply equals-null.cocci
[alt-git.git] / t / t1091-sparse-checkout-builtin.sh
blob42776984fe77912c8bc6a8450935c08134858946
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 git -C repo ls-files --sparse >sparse &&
238 git -C repo sparse-checkout disable &&
239 git -C repo ls-files --sparse >full &&
241 cat >expect <<-\EOF &&
242 @@ -1,4 +1,7 @@
244 -deep/
245 -folder1/
246 -folder2/
247 +deep/a
248 +deep/deeper1/a
249 +deep/deeper1/deepest/a
250 +deep/deeper2/a
251 +folder1/a
252 +folder2/a
255 diff -u sparse full | tail -n +3 >actual &&
256 test_cmp expect actual &&
258 git -C repo config --list >config &&
259 ! grep index.sparse config
263 test_expect_success 'cone mode: init and set' '
264 git -C repo sparse-checkout init --cone &&
265 git -C repo config --list >config &&
266 test_i18ngrep "core.sparsecheckoutcone=true" config &&
267 list_files repo >dir &&
268 echo a >expect &&
269 test_cmp expect dir &&
270 git -C repo sparse-checkout set deep/deeper1/deepest/ 2>err &&
271 test_must_be_empty err &&
272 check_files repo a deep &&
273 check_files repo/deep a deeper1 &&
274 check_files repo/deep/deeper1 a deepest &&
275 cat >expect <<-\EOF &&
277 !/*/
278 /deep/
279 !/deep/*/
280 /deep/deeper1/
281 !/deep/deeper1/*/
282 /deep/deeper1/deepest/
284 test_cmp expect repo/.git/info/sparse-checkout &&
285 git -C repo sparse-checkout set --stdin 2>err <<-\EOF &&
286 folder1
287 folder2
289 test_must_be_empty err &&
290 check_files repo a folder1 folder2
293 test_expect_success 'cone mode: list' '
294 cat >expect <<-\EOF &&
295 folder1
296 folder2
298 git -C repo sparse-checkout set --stdin <expect &&
299 git -C repo sparse-checkout list >actual 2>err &&
300 test_must_be_empty err &&
301 test_cmp expect actual
304 test_expect_success 'cone mode: set with nested folders' '
305 git -C repo sparse-checkout set deep deep/deeper1/deepest 2>err &&
306 test_line_count = 0 err &&
307 cat >expect <<-\EOF &&
309 !/*/
310 /deep/
312 test_cmp repo/.git/info/sparse-checkout expect
315 test_expect_success 'cone mode: add independent path' '
316 git -C repo sparse-checkout set deep/deeper1 &&
317 git -C repo sparse-checkout add folder1 &&
318 cat >expect <<-\EOF &&
320 !/*/
321 /deep/
322 !/deep/*/
323 /deep/deeper1/
324 /folder1/
326 test_cmp expect repo/.git/info/sparse-checkout &&
327 check_files repo a deep folder1
330 test_expect_success 'cone mode: add sibling path' '
331 git -C repo sparse-checkout set deep/deeper1 &&
332 git -C repo sparse-checkout add deep/deeper2 &&
333 cat >expect <<-\EOF &&
335 !/*/
336 /deep/
337 !/deep/*/
338 /deep/deeper1/
339 /deep/deeper2/
341 test_cmp expect repo/.git/info/sparse-checkout &&
342 check_files repo a deep
345 test_expect_success 'cone mode: add parent path' '
346 git -C repo sparse-checkout set deep/deeper1 folder1 &&
347 git -C repo sparse-checkout add deep &&
348 cat >expect <<-\EOF &&
350 !/*/
351 /deep/
352 /folder1/
354 test_cmp expect repo/.git/info/sparse-checkout &&
355 check_files repo a deep folder1
358 test_expect_success 'not-up-to-date does not block rest of sparsification' '
359 test_when_finished git -C repo sparse-checkout disable &&
360 test_when_finished git -C repo reset --hard &&
361 git -C repo sparse-checkout set deep &&
363 echo update >repo/deep/deeper2/a &&
364 cp repo/.git/info/sparse-checkout expect &&
365 test_write_lines "!/deep/*/" "/deep/deeper1/" >>expect &&
367 git -C repo sparse-checkout set deep/deeper1 2>err &&
369 test_i18ngrep "The following paths are not up to date" err &&
370 test_cmp expect repo/.git/info/sparse-checkout &&
371 check_files repo/deep a deeper1 deeper2 &&
372 check_files repo/deep/deeper1 a deepest &&
373 check_files repo/deep/deeper1/deepest a &&
374 check_files repo/deep/deeper2 a
377 test_expect_success 'revert to old sparse-checkout on empty update' '
378 git init empty-test &&
380 echo >file &&
381 git add file &&
382 git commit -m "test" &&
383 git sparse-checkout set nothing 2>err &&
384 test_i18ngrep ! "Sparse checkout leaves no entry on working directory" err &&
385 test_i18ngrep ! ".git/index.lock" err &&
386 git sparse-checkout set file
390 test_expect_success 'fail when lock is taken' '
391 test_when_finished rm -rf repo/.git/info/sparse-checkout.lock &&
392 touch repo/.git/info/sparse-checkout.lock &&
393 test_must_fail git -C repo sparse-checkout set deep 2>err &&
394 test_i18ngrep "Unable to create .*\.lock" err
397 test_expect_success '.gitignore should not warn about cone mode' '
398 git -C repo config --worktree core.sparseCheckoutCone true &&
399 echo "**/bin/*" >repo/.gitignore &&
400 git -C repo reset --hard 2>err &&
401 test_i18ngrep ! "disabling cone patterns" err
404 test_expect_success 'sparse-checkout (init|set|disable) warns with dirty status' '
405 git clone repo dirty &&
406 echo dirty >dirty/folder1/a &&
408 git -C dirty sparse-checkout init 2>err &&
409 test_i18ngrep "warning.*The following paths are not up to date" err &&
411 git -C dirty sparse-checkout set /folder2/* /deep/deeper1/* 2>err &&
412 test_i18ngrep "warning.*The following paths are not up to date" err &&
413 test_path_is_file dirty/folder1/a &&
415 git -C dirty sparse-checkout disable 2>err &&
416 test_must_be_empty err &&
418 git -C dirty reset --hard &&
419 git -C dirty sparse-checkout init &&
420 git -C dirty sparse-checkout set /folder2/* /deep/deeper1/* &&
421 test_path_is_missing dirty/folder1/a &&
422 git -C dirty sparse-checkout disable &&
423 test_path_is_file dirty/folder1/a
426 test_expect_success 'sparse-checkout (init|set|disable) warns with unmerged status' '
427 git clone repo unmerged &&
429 cat >input <<-EOF &&
430 0 $ZERO_OID folder1/a
431 100644 $(git -C unmerged rev-parse HEAD:folder1/a) 1 folder1/a
433 git -C unmerged update-index --index-info <input &&
435 git -C unmerged sparse-checkout init 2>err &&
436 test_i18ngrep "warning.*The following paths are unmerged" err &&
438 git -C unmerged sparse-checkout set /folder2/* /deep/deeper1/* 2>err &&
439 test_i18ngrep "warning.*The following paths are unmerged" err &&
440 test_path_is_file dirty/folder1/a &&
442 git -C unmerged sparse-checkout disable 2>err &&
443 test_i18ngrep "warning.*The following paths are unmerged" err &&
445 git -C unmerged reset --hard &&
446 git -C unmerged sparse-checkout init &&
447 git -C unmerged sparse-checkout set /folder2/* /deep/deeper1/* &&
448 git -C unmerged sparse-checkout disable
451 test_expect_failure 'sparse-checkout reapply' '
452 git clone repo tweak &&
454 echo dirty >tweak/deep/deeper2/a &&
456 cat >input <<-EOF &&
457 0 $ZERO_OID folder1/a
458 100644 $(git -C tweak rev-parse HEAD:folder1/a) 1 folder1/a
460 git -C tweak update-index --index-info <input &&
462 git -C tweak sparse-checkout init --cone 2>err &&
463 test_i18ngrep "warning.*The following paths are not up to date" err &&
464 test_i18ngrep "warning.*The following paths are unmerged" err &&
466 git -C tweak sparse-checkout set folder2 deep/deeper1 2>err &&
467 test_i18ngrep "warning.*The following paths are not up to date" err &&
468 test_i18ngrep "warning.*The following paths are unmerged" err &&
470 git -C tweak sparse-checkout reapply 2>err &&
471 test_i18ngrep "warning.*The following paths are not up to date" err &&
472 test_path_is_file tweak/deep/deeper2/a &&
473 test_i18ngrep "warning.*The following paths are unmerged" err &&
474 test_path_is_file tweak/folder1/a &&
476 git -C tweak checkout HEAD deep/deeper2/a &&
477 git -C tweak sparse-checkout reapply 2>err &&
478 test_i18ngrep ! "warning.*The following paths are not up to date" err &&
479 test_path_is_missing tweak/deep/deeper2/a &&
480 test_i18ngrep "warning.*The following paths are unmerged" err &&
481 test_path_is_file tweak/folder1/a &&
483 # NEEDSWORK: We are asking to update a file outside of the
484 # sparse-checkout cone, but this is no longer allowed.
485 git -C tweak add folder1/a &&
486 git -C tweak sparse-checkout reapply 2>err &&
487 test_must_be_empty err &&
488 test_path_is_missing tweak/deep/deeper2/a &&
489 test_path_is_missing tweak/folder1/a &&
491 git -C tweak sparse-checkout disable
494 test_expect_success 'cone mode: set with core.ignoreCase=true' '
495 rm repo/.git/info/sparse-checkout &&
496 git -C repo sparse-checkout init --cone &&
497 git -C repo -c core.ignoreCase=true sparse-checkout set folder1 &&
498 cat >expect <<-\EOF &&
500 !/*/
501 /folder1/
503 test_cmp expect repo/.git/info/sparse-checkout &&
504 check_files repo a folder1
507 test_expect_success 'interaction with submodules' '
508 git clone repo super &&
510 cd super &&
511 mkdir modules &&
512 git submodule add ../repo modules/child &&
513 git add . &&
514 git commit -m "add submodule" &&
515 git sparse-checkout init --cone &&
516 git sparse-checkout set folder1
517 ) &&
518 check_files super a folder1 modules &&
519 check_files super/modules/child a deep folder1 folder2
522 test_expect_success 'different sparse-checkouts with worktrees' '
523 git -C repo worktree add --detach ../worktree &&
524 check_files worktree "a deep folder1 folder2" &&
525 git -C worktree sparse-checkout init --cone &&
526 git -C repo sparse-checkout set folder1 &&
527 git -C worktree sparse-checkout set deep/deeper1 &&
528 check_files repo a folder1 &&
529 check_files worktree a deep
532 test_expect_success 'set using filename keeps file on-disk' '
533 git -C repo sparse-checkout set a deep &&
534 cat >expect <<-\EOF &&
536 !/*/
538 /deep/
540 test_cmp expect repo/.git/info/sparse-checkout &&
541 check_files repo a deep
544 check_read_tree_errors () {
545 REPO=$1
546 FILES=$2
547 ERRORS=$3
548 git -C $REPO -c core.sparseCheckoutCone=false read-tree -mu HEAD 2>err &&
549 test_must_be_empty err &&
550 check_files $REPO "$FILES" &&
551 git -C $REPO read-tree -mu HEAD 2>err &&
552 if test -z "$ERRORS"
553 then
554 test_must_be_empty err
555 else
556 test_i18ngrep "$ERRORS" err
557 fi &&
558 check_files $REPO $FILES
561 test_expect_success 'pattern-checks: /A/**' '
562 cat >repo/.git/info/sparse-checkout <<-\EOF &&
564 !/*/
565 /folder1/**
567 check_read_tree_errors repo "a folder1" "disabling cone pattern matching"
570 test_expect_success 'pattern-checks: /A/**/B/' '
571 cat >repo/.git/info/sparse-checkout <<-\EOF &&
573 !/*/
574 /deep/**/deepest
576 check_read_tree_errors repo "a deep" "disabling cone pattern matching" &&
577 check_files repo/deep "deeper1" &&
578 check_files repo/deep/deeper1 "deepest"
581 test_expect_success 'pattern-checks: too short' '
582 cat >repo/.git/info/sparse-checkout <<-\EOF &&
584 !/*/
587 check_read_tree_errors repo "a" "disabling cone pattern matching"
589 test_expect_success 'pattern-checks: not too short' '
590 cat >repo/.git/info/sparse-checkout <<-\EOF &&
592 !/*/
595 git -C repo read-tree -mu HEAD 2>err &&
596 test_must_be_empty err &&
597 check_files repo a
600 test_expect_success 'pattern-checks: trailing "*"' '
601 cat >repo/.git/info/sparse-checkout <<-\EOF &&
603 !/*/
606 check_read_tree_errors repo "a" "disabling cone pattern matching"
609 test_expect_success 'pattern-checks: starting "*"' '
610 cat >repo/.git/info/sparse-checkout <<-\EOF &&
612 !/*/
613 *eep/
615 check_read_tree_errors repo "a deep" "disabling cone pattern matching"
618 test_expect_success 'pattern-checks: contained glob characters' '
619 for c in "[a]" "\\" "?" "*"
621 cat >repo/.git/info/sparse-checkout <<-EOF &&
623 !/*/
624 something$c-else/
626 check_read_tree_errors repo "a" "disabling cone pattern matching" || return 1
627 done
630 test_expect_success BSLASHPSPEC 'pattern-checks: escaped characters' '
631 git clone repo escaped &&
632 TREEOID=$(git -C escaped rev-parse HEAD:folder1) &&
633 NEWTREE=$(git -C escaped mktree <<-EOF
634 $(git -C escaped ls-tree HEAD)
635 040000 tree $TREEOID zbad\\dir
636 040000 tree $TREEOID zdoes*exist
637 040000 tree $TREEOID zglob[!a]?
639 ) &&
640 COMMIT=$(git -C escaped commit-tree $NEWTREE -p HEAD) &&
641 git -C escaped reset --hard $COMMIT &&
642 check_files escaped "a deep folder1 folder2 zbad\\dir zdoes*exist" zglob[!a]? &&
643 git -C escaped sparse-checkout init --cone &&
644 git -C escaped sparse-checkout set zbad\\dir/bogus "zdoes*not*exist" "zdoes*exist" "zglob[!a]?" &&
645 cat >expect <<-\EOF &&
647 !/*/
648 /zbad\\dir/
649 !/zbad\\dir/*/
650 /zbad\\dir/bogus/
651 /zdoes\*exist/
652 /zdoes\*not\*exist/
653 /zglob\[!a]\?/
655 test_cmp expect escaped/.git/info/sparse-checkout &&
656 check_read_tree_errors escaped "a zbad\\dir zdoes*exist zglob[!a]?" &&
657 git -C escaped ls-tree -d --name-only HEAD >list-expect &&
658 git -C escaped sparse-checkout set --stdin <list-expect &&
659 cat >expect <<-\EOF &&
661 !/*/
662 /deep/
663 /folder1/
664 /folder2/
665 /zbad\\dir/
666 /zdoes\*exist/
667 /zglob\[!a]\?/
669 test_cmp expect escaped/.git/info/sparse-checkout &&
670 check_files escaped "a deep folder1 folder2 zbad\\dir zdoes*exist" zglob[!a]? &&
671 git -C escaped sparse-checkout list >list-actual &&
672 test_cmp list-expect list-actual
675 test_expect_success MINGW 'cone mode replaces backslashes with slashes' '
676 git -C repo sparse-checkout set deep\\deeper1 &&
677 cat >expect <<-\EOF &&
679 !/*/
680 /deep/
681 !/deep/*/
682 /deep/deeper1/
684 test_cmp expect repo/.git/info/sparse-checkout &&
685 check_files repo a deep &&
686 check_files repo/deep a deeper1
689 test_expect_success 'cone mode clears ignored subdirectories' '
690 rm repo/.git/info/sparse-checkout &&
692 git -C repo sparse-checkout init --cone &&
693 git -C repo sparse-checkout set deep/deeper1 &&
695 cat >repo/.gitignore <<-\EOF &&
696 obj/
700 git -C repo add .gitignore &&
701 git -C repo commit -m ".gitignore" &&
703 mkdir -p repo/obj repo/folder1/obj repo/deep/deeper2/obj &&
704 for file in folder1/obj/a obj/a folder1/file.o folder1.o \
705 deep/deeper2/obj/a deep/deeper2/file.o file.o
707 echo ignored >repo/$file || return 1
708 done &&
710 git -C repo status --porcelain=v2 >out &&
711 test_must_be_empty out &&
713 git -C repo sparse-checkout reapply &&
714 test_path_is_missing repo/folder1 &&
715 test_path_is_missing repo/deep/deeper2 &&
716 test_path_is_dir repo/obj &&
717 test_path_is_file repo/file.o &&
719 git -C repo status --porcelain=v2 >out &&
720 test_must_be_empty out &&
722 git -C repo sparse-checkout set deep/deeper2 &&
723 test_path_is_missing repo/deep/deeper1 &&
724 test_path_is_dir repo/deep/deeper2 &&
725 test_path_is_dir repo/obj &&
726 test_path_is_file repo/file.o &&
728 >repo/deep/deeper2/ignored.o &&
729 >repo/deep/deeper2/untracked &&
731 # When an untracked file is in the way, all untracked files
732 # (even ignored files) are preserved.
733 git -C repo sparse-checkout set folder1 2>err &&
734 grep "contains untracked files" err &&
735 test_path_is_file repo/deep/deeper2/ignored.o &&
736 test_path_is_file repo/deep/deeper2/untracked &&
738 # The rest of the cone matches expectation
739 test_path_is_missing repo/deep/deeper1 &&
740 test_path_is_dir repo/obj &&
741 test_path_is_file repo/file.o &&
743 git -C repo status --porcelain=v2 >out &&
744 echo "? deep/deeper2/untracked" >expect &&
745 test_cmp expect out
748 test_expect_success 'malformed cone-mode patterns' '
749 git -C repo sparse-checkout init --cone &&
750 mkdir -p repo/foo/bar &&
751 touch repo/foo/bar/x repo/foo/y &&
752 cat >repo/.git/info/sparse-checkout <<-\EOF &&
754 !/*/
755 /foo/
756 !/foo/*/
757 /foo/\*/
760 # Listing the patterns will notice the duplicate pattern and
761 # emit a warning. It will list the patterns directly instead
762 # of using the cone-mode translation to a set of directories.
763 git -C repo sparse-checkout list >actual 2>err &&
764 test_cmp repo/.git/info/sparse-checkout actual &&
765 grep "warning: your sparse-checkout file may have issues: pattern .* is repeated" err &&
766 grep "warning: disabling cone pattern matching" err
769 test_done