214
}
215
216
basic_cruft_pack_tests never
217
+basic_cruft_pack_tests 2.weeks.ago
218
+
219
+test_expect_success 'cruft tags rescue tagged objects' '
220
+ git init repo &&
221
+ test_when_finished "rm -fr repo" &&
222
+ (
223
+ cd repo &&
224
+
225
+ test_commit packed &&
226
+ git repack -Ad &&
227
+
228
+ test_commit tagged &&
229
+ git tag -a annotated -m tag &&
230
+
231
+ git rev-list --objects --no-object-names packed.. >objects &&
232
+ while read oid
233
+ do
234
+ test-tool chmtime -1000 \
235
+ "$objdir/$(test_oid_to_path $oid)"
236
+ done <objects &&
237
+
238
+ test-tool chmtime -500 \
239
+ "$objdir/$(test_oid_to_path $(git rev-parse annotated))" &&
240
+
241
+ keep="$(basename "$(ls $packdir/pack-*.pack)")" &&
242
+ cruft="$(echo $keep | git pack-objects --cruft \
243
+ --cruft-expiration=750.seconds.ago \
244
+ $packdir/pack)" &&
245
+ test-tool pack-mtimes "pack-$cruft.mtimes" >actual.raw &&
246
+ cut -f1 -d" " <actual.raw | sort >actual &&
247
+
248
+ (
249
+ cat objects &&
250
+ git rev-parse annotated
251
+ ) >expect.raw &&
252
+ sort <expect.raw >expect &&
253
+
254
+ test_cmp expect actual &&
255
+ cat actual
256
+ )
257
+'
258
+
259
+test_expect_success 'cruft commits rescue parents, trees' '
260
+ git init repo &&
261
+ test_when_finished "rm -fr repo" &&
262
+ (
263
+ cd repo &&
264
+
265
+ test_commit packed &&
266
+ git repack -Ad &&
267
+
268
+ test_commit old &&
269
+ test_commit new &&
270
+
271
+ git rev-list --objects --no-object-names packed..new >objects &&
272
+ while read object
273
+ do
274
+ test-tool chmtime -1000 \
275
+ "$objdir/$(test_oid_to_path $object)"
276
+ done <objects &&
277
+ test-tool chmtime +500 "$objdir/$(test_oid_to_path \
278
+ $(git rev-parse HEAD))" &&
279
+
280
+ keep="$(basename "$(ls $packdir/pack-*.pack)")" &&
281
+ cruft="$(echo $keep | git pack-objects --cruft \
282
+ --cruft-expiration=750.seconds.ago \
283
+ $packdir/pack)" &&
284
+ test-tool pack-mtimes "pack-$cruft.mtimes" >actual.raw &&
285
+
286
+ cut -d" " -f1 <actual.raw | sort >actual &&
287
+ sort <objects >expect &&
288
+
289
+ test_cmp expect actual
290
+ )
291
+'
292
+
293
+test_expect_success 'cruft trees rescue sub-trees, blobs' '
294
+ git init repo &&
295
+ test_when_finished "rm -fr repo" &&
296
+ (
297
+ cd repo &&
298
+
299
+ test_commit packed &&
300
+ git repack -Ad &&
301
+
302
+ mkdir -p dir/sub &&
303
+ echo foo >foo &&
304
+ echo bar >dir/bar &&
305
+ echo baz >dir/sub/baz &&
306
+
307
+ test_tick &&
308
+ git add . &&
309
+ git commit -m "pruned" &&
310
+
311
+ test-tool chmtime -1000 "$objdir/$(test_oid_to_path $(git rev-parse HEAD))" &&
312
+ test-tool chmtime -1000 "$objdir/$(test_oid_to_path $(git rev-parse HEAD^{tree}))" &&
313
+ test-tool chmtime -1000 "$objdir/$(test_oid_to_path $(git rev-parse HEAD:foo))" &&
314
+ test-tool chmtime -500 "$objdir/$(test_oid_to_path $(git rev-parse HEAD:dir))" &&
315
+ test-tool chmtime -1000 "$objdir/$(test_oid_to_path $(git rev-parse HEAD:dir/bar))" &&
316
+ test-tool chmtime -1000 "$objdir/$(test_oid_to_path $(git rev-parse HEAD:dir/sub))" &&
317
+ test-tool chmtime -1000 "$objdir/$(test_oid_to_path $(git rev-parse HEAD:dir/sub/baz))" &&
318
+
319
+ keep="$(basename "$(ls $packdir/pack-*.pack)")" &&
320
+ cruft="$(echo $keep | git pack-objects --cruft \
321
+ --cruft-expiration=750.seconds.ago \
322
+ $packdir/pack)" &&
323
+ test-tool pack-mtimes "pack-$cruft.mtimes" >actual.raw &&
324
+ cut -f1 -d" " <actual.raw | sort >actual &&
325
+
326
+ git rev-parse HEAD:dir HEAD:dir/bar HEAD:dir/sub HEAD:dir/sub/baz >expect.raw &&
327
+ sort <expect.raw >expect &&
328
+
329
+ test_cmp expect actual
330
+ )
331
+'
332
+
333
+test_expect_success 'expired objects are pruned' '
334
+ git init repo &&
335
+ test_when_finished "rm -fr repo" &&
336
+ (
337
+ cd repo &&
338
+
339
+ test_commit packed &&
340
+ git repack -Ad &&
341
+
342
+ test_commit pruned &&
343
+
344
+ git rev-list --objects --no-object-names packed..pruned >objects &&
345
+ while read object
346
+ do
347
+ test-tool chmtime -1000 \
348
+ "$objdir/$(test_oid_to_path $object)"
349
+ done <objects &&
350
+
351
+ keep="$(basename "$(ls $packdir/pack-*.pack)")" &&
352
+ cruft="$(echo $keep | git pack-objects --cruft \
353
+ --cruft-expiration=750.seconds.ago \
354
+ $packdir/pack)" &&
355
+
356
+ test-tool pack-mtimes "pack-$cruft.mtimes" >actual &&
357
+ test_must_be_empty actual
358
+ )
359
+'
360
361
test_done