sparse-index: update command for expand/collapse test
[git.git] / t / t3602-rm-sparse-checkout.sh
blobe9e9a15c74cd339d592f64e31c3bb1e1adfde845
1 #!/bin/sh
3 test_description='git rm in sparse checked out working trees'
5 . ./test-lib.sh
7 test_expect_success 'setup' "
8 mkdir -p sub/dir &&
9 touch a b c sub/d sub/dir/e &&
10 git add -A &&
11 git commit -m files &&
13 cat >sparse_error_header <<-EOF &&
14 The following pathspecs didn't match any eligible path, but they do match index
15 entries outside the current sparse checkout:
16 EOF
18 cat >sparse_hint <<-EOF &&
19 hint: Disable or modify the sparsity rules if you intend to update such entries.
20 hint: Disable this message with \"git config advice.updateSparsePath false\"
21 EOF
23 echo b | cat sparse_error_header - >sparse_entry_b_error &&
24 cat sparse_entry_b_error sparse_hint >b_error_and_hint
27 for opt in "" -f --dry-run
29 test_expect_success "rm${opt:+ $opt} does not remove sparse entries" '
30 git sparse-checkout set a &&
31 test_must_fail git rm $opt b 2>stderr &&
32 test_cmp b_error_and_hint stderr &&
33 git ls-files --error-unmatch b
35 done
37 test_expect_success 'recursive rm does not remove sparse entries' '
38 git reset --hard &&
39 git sparse-checkout set sub/dir &&
40 git rm -r sub &&
41 git status --porcelain -uno >actual &&
42 echo "D sub/dir/e" >expected &&
43 test_cmp expected actual
46 test_expect_success 'rm obeys advice.updateSparsePath' '
47 git reset --hard &&
48 git sparse-checkout set a &&
49 test_must_fail git -c advice.updateSparsePath=false rm b 2>stderr &&
50 test_cmp sparse_entry_b_error stderr
53 test_expect_success 'do not advice about sparse entries when they do not match the pathspec' '
54 git reset --hard &&
55 git sparse-checkout set a &&
56 test_must_fail git rm nonexistent 2>stderr &&
57 grep "fatal: pathspec .nonexistent. did not match any files" stderr &&
58 ! grep -F -f sparse_error_header stderr
61 test_expect_success 'do not warn about sparse entries when pathspec matches dense entries' '
62 git reset --hard &&
63 git sparse-checkout set a &&
64 git rm "[ba]" 2>stderr &&
65 test_must_be_empty stderr &&
66 git ls-files --error-unmatch b &&
67 test_must_fail git ls-files --error-unmatch a
70 test_expect_success 'do not warn about sparse entries with --ignore-unmatch' '
71 git reset --hard &&
72 git sparse-checkout set a &&
73 git rm --ignore-unmatch b 2>stderr &&
74 test_must_be_empty stderr &&
75 git ls-files --error-unmatch b
78 test_done