3 # Copyright (c) 2008 Nguyễn Thái Ngọc Duy
6 test_description='test worktree writing operations when skip-worktree is used'
10 test_expect_success 'setup' '
12 echo modified >> init.t &&
14 git add init.t added &&
15 git commit -m "modified and added" &&
19 test_expect_success 'read-tree updates worktree, absent case' '
20 git checkout -f top &&
21 git update-index --skip-worktree init.t &&
23 git read-tree -m -u HEAD^ &&
24 echo init > expected &&
25 test_cmp expected init.t
28 test_expect_success 'read-tree updates worktree, dirty case' '
29 git checkout -f top &&
30 git update-index --skip-worktree init.t &&
31 echo dirty >> init.t &&
32 test_must_fail git read-tree -m -u HEAD^ &&
33 grep -q dirty init.t &&
34 test "$(git ls-files -t init.t)" = "S init.t" &&
35 git update-index --no-skip-worktree init.t
38 test_expect_success 'read-tree removes worktree, absent case' '
39 git checkout -f top &&
40 git update-index --skip-worktree added &&
42 git read-tree -m -u HEAD^ &&
46 test_expect_success 'read-tree removes worktree, dirty case' '
47 git checkout -f top &&
48 git update-index --skip-worktree added &&
49 echo dirty >> added &&
50 test_must_fail git read-tree -m -u HEAD^ &&
51 grep -q dirty added &&
52 test "$(git ls-files -t added)" = "S added" &&
53 git update-index --no-skip-worktree added
56 NULL_SHA1=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
60 git update-index --remove 1 &&
61 git update-index --add --cacheinfo 100644 $NULL_SHA1 1 &&
62 git update-index --skip-worktree 1
66 echo "100644 $NULL_SHA1 0 1" > expected &&
67 git ls-files --stage 1 > result &&
68 test_cmp expected result &&
73 git update-index --force-remove 1 &&
75 git update-index --add --cacheinfo 100644 $NULL_SHA1 1 &&
76 git update-index --skip-worktree 1
80 echo "100644 $NULL_SHA1 0 1" > expected &&
81 git ls-files --stage 1 > result &&
82 test_cmp expected result &&
95 test_expect_success 'index setup' '
96 git checkout -f init &&
98 touch ./1 ./2 sub/1 sub/2 &&
99 git add 1 2 sub/1 sub/2 &&
100 git update-index --skip-worktree 1 sub/1 &&
101 git ls-files -t > result &&
102 test_cmp expected result
105 test_expect_success 'git-add ignores worktree content' '
111 test_expect_success 'git-add ignores worktree content' '
117 test_expect_success 'git-rm fails if worktree is dirty' '
119 test_must_fail git rm 1 &&
124 Would remove expected
127 test_expect_success 'git-clean, absent case' '
129 git clean -n > result &&
130 test_i18ncmp expected result
133 test_expect_success 'git-clean, dirty case' '
135 git clean -n > result &&
136 test_i18ncmp expected result
139 #TODO test_expect_failure 'git-apply adds file' false
140 #TODO test_expect_failure 'git-apply updates file' false
141 #TODO test_expect_failure 'git-apply removes file' false
142 #TODO test_expect_failure 'git-mv to skip-worktree' false
143 #TODO test_expect_failure 'git-mv from skip-worktree' false
144 #TODO test_expect_failure 'git-checkout' false