10
packdir=$objdir/pack
11
midx=$objdir/pack/multi-pack-index
12
13
+packed_objects () {
14
+ git show-index <"$1" >tmp-object-list &&
15
+ cut -d' ' -f2 tmp-object-list | sort &&
16
+ rm tmp-object-list
17
+ }
18
+
19
test_expect_success '--geometric with no packs' '
20
git init geometric &&
21
test_when_finished "rm -fr geometric" &&
367
test_cmp expected-files actual-files
368
'
369
370
+test_expect_success '--geometric -l with non-intact geometric sequence across ODBs' '
371
+ test_when_finished "rm -fr shared member" &&
372
+
373
+ git init shared &&
374
+ test_commit_bulk -C shared --start=1 1 &&
375
+
376
+ git clone --shared shared member &&
377
+ test_commit_bulk -C member --start=2 1 &&
378
+
379
+ # Verify that our assumptions actually hold: both generated packfiles
380
+ # should have three objects and should be non-equal.
381
+ packed_objects shared/.git/objects/pack/pack-*.idx >shared-objects &&
382
+ packed_objects member/.git/objects/pack/pack-*.idx >member-objects &&
383
+ test_line_count = 3 shared-objects &&
384
+ test_line_count = 3 member-objects &&
385
+ ! test_cmp shared-objects member-objects &&
386
+
387
+ # Perform the geometric repack. With `-l`, we should only see the local
388
+ # packfile and thus arrive at the conclusion that the geometric
389
+ # sequence is intact. We thus expect no changes.
390
+ #
391
+ # Note that we are tweaking mtimes of the packfiles so that we can
392
+ # verify they did not change. This is done in order to detect the case
393
+ # where we do repack objects, but the resulting packfile is the same.
394
+ test-tool chmtime --verbose =0 member/.git/objects/pack/* >expected-member-packs &&
395
+ git -C member repack --geometric=2 -l -d &&
396
+ test-tool chmtime --verbose member/.git/objects/pack/* >actual-member-packs &&
397
+ test_cmp expected-member-packs actual-member-packs &&
398
+
399
+ {
400
+ packed_objects shared/.git/objects/pack/pack-*.idx &&
401
+ packed_objects member/.git/objects/pack/pack-*.idx
402
+ } | sort >expected-objects &&
403
+
404
+ # On the other hand, when doing a non-local geometric repack we should
405
+ # see both packfiles and thus repack them. We expect that the shared
406
+ # object database was not changed.
407
+ test-tool chmtime --verbose =0 shared/.git/objects/pack/* >expected-shared-packs &&
408
+ git -C member repack --geometric=2 -d &&
409
+ test-tool chmtime --verbose shared/.git/objects/pack/* >actual-shared-packs &&
410
+ test_cmp expected-shared-packs actual-shared-packs &&
411
+
412
+ # Furthermore, we expect that the member repository now has a single
413
+ # packfile that contains the combined shared and non-shared objects.
414
+ ls member/.git/objects/pack/pack-*.idx >actual &&
415
+ test_line_count = 1 actual &&
416
+ packed_objects member/.git/objects/pack/pack-*.idx >actual-objects &&
417
+ test_line_count = 6 actual-objects &&
418
+ test_cmp expected-objects actual-objects
419
+'
420
+
421
test_done