119
test_cmp expect actual
120
'
121
122
+test_expect_success 'create a few commits' '
123
+ git commit-tree -m "Duplicate Entries" two^{tree} >commit_id &&
124
+ git branch base $(cat commit_id) &&
125
+
126
+ git commit-tree -p $(cat commit_id) -m "Just one" three^{tree} >up &&
127
+ git branch update $(cat up) &&
128
+
129
+ git commit-tree -p $(cat up) -m "Back to weird" two^{tree} >final &&
130
+ git branch final $(cat final) &&
131
+
132
+ rm commit_id up final
133
+'
134
+
135
+test_expect_failure 'git read-tree does not segfault' '
136
+ test_when_finished rm .git/index.lock &&
137
+ test_might_fail git read-tree --reset base
138
+'
139
+
140
+test_expect_failure 'reset --hard does not segfault' '
141
+ test_when_finished rm .git/index.lock &&
142
+ git checkout base &&
143
+ test_might_fail git reset --hard
144
+'
145
+
146
+test_expect_failure 'git diff HEAD does not segfault' '
147
+ git checkout base &&
148
+ GIT_TEST_CHECK_CACHE_TREE=false &&
149
+ git reset --hard &&
150
+ test_might_fail git diff HEAD
151
+'
152
+
153
+test_expect_failure 'can switch to another branch when status is empty' '
154
+ git clean -ffdqx &&
155
+ git status --porcelain -uno >actual &&
156
+ test_must_be_empty actual &&
157
+ git checkout update
158
+'
159
+
160
+test_expect_success 'forcibly switch to another branch, verify status empty' '
161
+ git checkout -f update &&
162
+ git status --porcelain -uno >actual &&
163
+ test_must_be_empty actual
164
+'
165
+
166
+test_expect_success 'fast-forward from non-duplicate entries to duplicate' '
167
+ git merge final
168
+'
169
+
170
+test_expect_failure 'clean status, switch branches, status still clean' '
171
+ git status --porcelain -uno >actual &&
172
+ test_must_be_empty actual &&
173
+ git checkout base &&
174
+ git status --porcelain -uno >actual &&
175
+ test_must_be_empty actual
176
+'
177
+
178
+test_expect_success 'switch to base branch and force status to be clean' '
179
+ git checkout base &&
180
+ GIT_TEST_CHECK_CACHE_TREE=false git reset --hard &&
181
+ git status --porcelain -uno >actual &&
182
+ test_must_be_empty actual
183
+'
184
+
185
+test_expect_failure 'fast-forward from duplicate entries to non-duplicate' '
186
+ git merge update
187
+'
188
+
189
test_done