builtin/gc.c: ignore cruft packs with `--keep-largest-pack`
[alt-git.git] / t / t7011-skip-worktree-reading.sh
blob4adac5acd57c56835608631c4ffe98f772d455bd
1 #!/bin/sh
3 # Copyright (c) 2008 Nguyễn Thái Ngọc Duy
6 test_description='skip-worktree bit test'
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
11 cat >expect.full <<EOF
12 H 1
13 H 2
14 H init.t
15 H sub/1
16 H sub/2
17 EOF
19 cat >expect.skip <<EOF
20 S 1
21 H 2
22 H init.t
23 S sub/1
24 H sub/2
25 EOF
27 setup_absent() {
28 test -f 1 && rm 1
29 git update-index --remove 1 &&
30 git update-index --add --cacheinfo 100644 $EMPTY_BLOB 1 &&
31 git update-index --skip-worktree 1
34 test_absent() {
35 echo "100644 $EMPTY_BLOB 0 1" > expected &&
36 git ls-files --stage 1 > result &&
37 test_cmp expected result &&
38 test ! -f 1
41 setup_dirty() {
42 git update-index --force-remove 1 &&
43 echo dirty > 1 &&
44 git update-index --add --cacheinfo 100644 $EMPTY_BLOB 1 &&
45 git update-index --skip-worktree 1
48 test_dirty() {
49 echo "100644 $EMPTY_BLOB 0 1" > expected &&
50 git ls-files --stage 1 > result &&
51 test_cmp expected result &&
52 echo dirty > expected
53 test_cmp expected 1
56 test_expect_success 'setup' '
57 test_commit init &&
58 mkdir sub &&
59 touch ./1 ./2 sub/1 sub/2 &&
60 git add 1 2 sub/1 sub/2 &&
61 git update-index --skip-worktree 1 sub/1 &&
62 git ls-files -t > result &&
63 test_cmp expect.skip result
66 test_expect_success 'update-index' '
67 setup_absent &&
68 git update-index 1 &&
69 test_absent
72 test_expect_success 'update-index' '
73 setup_dirty &&
74 git update-index 1 &&
75 test_dirty
78 test_expect_success 'update-index --remove' '
79 setup_absent &&
80 git update-index --remove 1 &&
81 test -z "$(git ls-files 1)" &&
82 test ! -f 1
85 test_expect_success 'update-index --remove' '
86 setup_dirty &&
87 git update-index --remove 1 &&
88 test -z "$(git ls-files 1)" &&
89 echo dirty > expected &&
90 test_cmp expected 1
93 test_expect_success 'ls-files --deleted' '
94 setup_absent &&
95 test -z "$(git ls-files -d)"
98 test_expect_success 'ls-files --deleted' '
99 setup_dirty &&
100 test -z "$(git ls-files -d)"
103 test_expect_success 'ls-files --modified' '
104 setup_absent &&
105 test -z "$(git ls-files -m)"
108 test_expect_success 'ls-files --modified' '
109 setup_dirty &&
110 test -z "$(git ls-files -m)"
113 echo ":000000 100644 $ZERO_OID $EMPTY_BLOB A 1" > expected
114 test_expect_success 'diff-index does not examine skip-worktree absent entries' '
115 setup_absent &&
116 git diff-index HEAD -- 1 > result &&
117 test_cmp expected result
120 test_expect_success 'diff-index does not examine skip-worktree dirty entries' '
121 setup_dirty &&
122 git diff-index HEAD -- 1 > result &&
123 test_cmp expected result
126 test_expect_success 'diff-files does not examine skip-worktree absent entries' '
127 setup_absent &&
128 test -z "$(git diff-files -- one)"
131 test_expect_success 'diff-files does not examine skip-worktree dirty entries' '
132 setup_dirty &&
133 test -z "$(git diff-files -- one)"
136 test_expect_success 'commit on skip-worktree absent entries' '
137 git reset &&
138 setup_absent &&
139 test_must_fail git commit -m null 1
142 test_expect_success 'commit on skip-worktree dirty entries' '
143 git reset &&
144 setup_dirty &&
145 test_must_fail git commit -m null 1
148 test_done