3 test_description='Intent to add'
7 test_expect_success 'intent to add' '
18 test_expect_success 'git status' '
19 git status --porcelain | grep -v actual >actual &&
20 cat >expect <<-\EOF &&
25 test_cmp expect actual
28 test_expect_success 'git status with porcelain v2' '
29 git status --porcelain=v2 | grep -v "^?" >actual &&
30 nam1=$(echo 1 | git hash-object --stdin) &&
31 nam2=$(git hash-object elif) &&
33 1 DA N... 100644 000000 100644 $nam1 $ZERO_OID 1.t
34 1 A. N... 000000 100644 100644 $ZERO_OID $nam2 elif
35 1 .A N... 000000 000000 100644 $ZERO_OID $ZERO_OID file
37 test_cmp expect actual
40 test_expect_success 'check result of "add -N"' '
41 git ls-files -s file >actual &&
42 empty=$(git hash-object --stdin </dev/null) &&
43 echo "100644 $empty 0 file" >expect &&
44 test_cmp expect actual
47 test_expect_success 'intent to add is just an ordinary empty blob' '
49 git ls-files -s file >actual &&
50 git ls-files -s elif | sed -e "s/elif/file/" >expect &&
51 test_cmp expect actual
54 test_expect_success 'intent to add does not clobber existing paths' '
55 git add -N file elif &&
56 empty=$(git hash-object --stdin </dev/null) &&
57 git ls-files -s >actual &&
58 ! grep "$empty" actual
61 test_expect_success 'i-t-a entry is simply ignored' '
63 git commit -a -m initial &&
70 git commit -m second &&
71 test $(git ls-tree HEAD -- nitfol | wc -l) = 0 &&
72 test $(git diff --name-only HEAD -- nitfol | wc -l) = 1 &&
73 test $(git diff --name-only --ita-invisible-in-index HEAD -- nitfol | wc -l) = 0 &&
74 test $(git diff --name-only --ita-invisible-in-index -- nitfol | wc -l) = 1
77 test_expect_success 'can commit with an unrelated i-t-a entry in index' '
79 echo bozbar >rezrov &&
83 git commit -m partial rezrov
86 test_expect_success 'can "commit -a" with an i-t-a entry' '
93 test_expect_success 'cache-tree invalidates i-t-a paths' '
101 git add -N dir/bar &&
102 git diff --cached --name-only >actual &&
103 echo dir/bar >expect &&
104 test_cmp expect actual &&
106 git write-tree >/dev/null &&
108 git diff --cached --name-only >actual &&
109 echo dir/bar >expect &&
110 test_cmp expect actual
113 test_expect_success 'cache-tree does not ignore dir that has i-t-a entries' '
114 git init ita-in-dir &&
124 git commit -m committed &&
125 git ls-tree -r HEAD >actual &&
130 test_expect_success 'cache-tree does skip dir that becomes empty' '
132 git init ita-in-dir &&
137 git add -N 1/2/3/4 &&
138 git write-tree >actual &&
139 echo $EMPTY_TREE >expected &&
140 test_cmp expected actual
144 test_expect_success 'commit: ita entries ignored in empty initial commit check' '
145 git init empty-initial-commit &&
147 cd empty-initial-commit &&
150 test_must_fail git commit -m nothing-new-here
154 test_expect_success 'commit: ita entries ignored in empty commit check' '
155 git init empty-subsequent-commit &&
157 cd empty-subsequent-commit &&
161 test_must_fail git commit -m nothing-new-here
165 test_expect_success 'rename detection finds the right names' '
166 git init rename-detection &&
168 cd rename-detection &&
169 echo contents >first &&
171 git commit -m first &&
175 git status | grep -v "^?" >actual.1 &&
176 test_i18ngrep "renamed: *first -> third" actual.1 &&
178 git status --porcelain | grep -v "^?" >actual.2 &&
179 cat >expected.2 <<-\EOF &&
182 test_cmp expected.2 actual.2 &&
184 hash=$(git hash-object third) &&
185 git status --porcelain=v2 | grep -v "^?" >actual.3 &&
186 cat >expected.3 <<-EOF &&
187 2 .R N... 100644 100644 100644 $hash $hash R100 third first
189 test_cmp expected.3 actual.3
193 test_expect_success 'double rename detection in status' '
194 git init rename-detection-2 &&
196 cd rename-detection-2 &&
197 echo contents >first &&
199 git commit -m first &&
200 git mv first second &&
204 git status | grep -v "^?" >actual.1 &&
205 test_i18ngrep "renamed: *first -> second" actual.1 &&
206 test_i18ngrep "renamed: *second -> third" actual.1 &&
208 git status --porcelain | grep -v "^?" >actual.2 &&
209 cat >expected.2 <<-\EOF &&
213 test_cmp expected.2 actual.2 &&
215 hash=$(git hash-object third) &&
216 git status --porcelain=v2 | grep -v "^?" >actual.3 &&
217 cat >expected.3 <<-EOF &&
218 2 R. N... 100644 100644 100644 $hash $hash R100 second first
219 2 .R N... 100644 100644 100644 $hash $hash R100 third second
221 test_cmp expected.3 actual.3