3 # Copyright (c) 2008 Nguyễn Thái Ngọc Duy
6 test_description='skip-worktree bit test'
10 cat >expect.full <<EOF
18 cat >expect.skip <<EOF
26 NULL_SHA1=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
27 ZERO_SHA0=0000000000000000000000000000000000000000
30 git update-index --remove 1 &&
31 git update-index --add --cacheinfo 100644 $NULL_SHA1 1 &&
32 git update-index --skip-worktree 1
36 echo "100644 $NULL_SHA1 0 1" > expected &&
37 git ls-files --stage 1 > result &&
38 test_cmp expected result &&
43 git update-index --force-remove 1 &&
45 git update-index --add --cacheinfo 100644 $NULL_SHA1 1 &&
46 git update-index --skip-worktree 1
50 echo "100644 $NULL_SHA1 0 1" > expected &&
51 git ls-files --stage 1 > result &&
52 test_cmp expected result &&
57 test_expect_success 'setup' '
60 touch ./1 ./2 sub/1 sub/2 &&
61 git add 1 2 sub/1 sub/2 &&
62 git update-index --skip-worktree 1 sub/1 &&
63 git ls-files -t > result &&
64 test_cmp expect.skip result
67 test_expect_success 'update-index' '
73 test_expect_success 'update-index' '
79 test_expect_success 'update-index --remove' '
81 git update-index --remove 1 &&
82 test -z "$(git ls-files 1)" &&
86 test_expect_success 'update-index --remove' '
88 git update-index --remove 1 &&
89 test -z "$(git ls-files 1)" &&
90 echo dirty > expected &&
94 test_expect_success 'ls-files --delete' '
96 test -z "$(git ls-files -d)"
99 test_expect_success 'ls-files --delete' '
101 test -z "$(git ls-files -d)"
104 test_expect_success 'ls-files --modified' '
106 test -z "$(git ls-files -m)"
109 test_expect_success 'ls-files --modified' '
111 test -z "$(git ls-files -m)"
114 test_expect_success 'grep with skip-worktree file' '
115 git update-index --no-skip-worktree 1 &&
117 git update-index 1 &&
118 git update-index --skip-worktree 1 &&
120 test "$(git grep --no-ext-grep test)" = "1:test"
123 echo ":000000 100644 $ZERO_SHA0 $NULL_SHA1 A 1" > expected
124 test_expect_success 'diff-index does not examine skip-worktree absent entries' '
126 git diff-index HEAD -- 1 > result &&
127 test_cmp expected result
130 test_expect_success 'diff-index does not examine skip-worktree dirty entries' '
132 git diff-index HEAD -- 1 > result &&
133 test_cmp expected result
136 test_expect_success 'diff-files does not examine skip-worktree absent entries' '
138 test -z "$(git diff-files -- one)"
141 test_expect_success 'diff-files does not examine skip-worktree dirty entries' '
143 test -z "$(git diff-files -- one)"
146 test_expect_success 'git-rm succeeds on skip-worktree absent entries' '
151 test_expect_success 'commit on skip-worktree absent entries' '
154 test_must_fail git commit -m null 1
157 test_expect_success 'commit on skip-worktree dirty entries' '
160 test_must_fail git commit -m null 1