194
test_i18ngrep "no remembered" actual
195
'
196
197
+test_expect_success 'resolve-undo keeps blobs from gc' '
198
+ git checkout -f main &&
199
+
200
+ # First make sure we do not have any cruft left in the object store
201
+ git repack -a -d &&
202
+ git prune --expire=now &&
203
+ git prune-packed &&
204
+ git gc --prune=now &&
205
+ git fsck --unreachable >cruft &&
206
+ test_must_be_empty cruft &&
207
+
208
+ # Now add three otherwise unreferenced blob objects to the index
209
+ git reset --hard &&
210
+ B1=$(echo "resolve undo test data 1" | git hash-object -w --stdin) &&
211
+ B2=$(echo "resolve undo test data 2" | git hash-object -w --stdin) &&
212
+ B3=$(echo "resolve undo test data 3" | git hash-object -w --stdin) &&
213
+ git update-index --add --index-info <<-EOF &&
214
+ 100644 $B1 1 frotz
215
+ 100644 $B2 2 frotz
216
+ 100644 $B3 3 frotz
217
+ EOF
218
+
219
+ # These three blob objects are reachable (only) from the index
220
+ git fsck --unreachable >cruft &&
221
+ test_must_be_empty cruft &&
222
+ # and they should be protected from GC
223
+ git gc --prune=now &&
224
+ git cat-file -e $B1 &&
225
+ git cat-file -e $B2 &&
226
+ git cat-file -e $B3 &&
227
+
228
+ # Now resolve the conflicted path
229
+ B0=$(echo "resolve undo test data 0" | git hash-object -w --stdin) &&
230
+ git update-index --add --cacheinfo 100644,$B0,frotz &&
231
+
232
+ # These three blob objects are now reachable only from the resolve-undo
233
+ git fsck --unreachable >cruft &&
234
+ test_must_be_empty cruft &&
235
+
236
+ # and they should survive GC
237
+ git gc --prune=now &&
238
+ git cat-file -e $B0 &&
239
+ git cat-file -e $B1 &&
240
+ git cat-file -e $B2 &&
241
+ git cat-file -e $B3 &&
242
+
243
+ # Now we switch away, which nukes resolve-undo, and
244
+ # blobs B0..B3 would become dangling. fsck should
245
+ # notice that they are now unreachable.
246
+ git checkout -f side &&
247
+ git fsck --unreachable >cruft &&
248
+ sort cruft >actual &&
249
+ sort <<-EOF >expect &&
250
+ unreachable blob $B0
251
+ unreachable blob $B1
252
+ unreachable blob $B2
253
+ unreachable blob $B3
254
+ EOF
255
+ test_cmp expect actual &&
256
+
257
+ # And they should go away when gc runs.
258
+ git gc --prune=now &&
259
+ git fsck --unreachable >cruft &&
260
+ test_must_be_empty cruft &&
261
+
262
+ test_must_fail git cat-file -e $B0 &&
263
+ test_must_fail git cat-file -e $B1 &&
264
+ test_must_fail git cat-file -e $B2 &&
265
+ test_must_fail git cat-file -e $B3
266
+'
267
+
268
test_done