Git fork

Merge branch 'rs/repack-without-loosening-promised-objects'

"git repack -A -d" in a partial clone unnecessarily loosened
objects in promisor pack.

* rs/repack-without-loosening-promised-objects:
repack: avoid loosening promisor objects in partial clones

+26 -3
+7 -1
builtin/pack-objects.c
··· 3479 3479 { 3480 3480 struct packed_git *p; 3481 3481 uint32_t i; 3482 + uint32_t loosened_objects_nr = 0; 3482 3483 struct object_id oid; 3483 3484 3484 3485 for (p = get_all_packs(the_repository); p; p = p->next) { ··· 3492 3493 nth_packed_object_id(&oid, p, i); 3493 3494 if (!packlist_find(&to_pack, &oid) && 3494 3495 !has_sha1_pack_kept_or_nonlocal(&oid) && 3495 - !loosened_object_can_be_discarded(&oid, p->mtime)) 3496 + !loosened_object_can_be_discarded(&oid, p->mtime)) { 3496 3497 if (force_object_loose(&oid, p->mtime)) 3497 3498 die(_("unable to force loose object")); 3499 + loosened_objects_nr++; 3500 + } 3498 3501 } 3499 3502 } 3503 + 3504 + trace2_data_intmax("pack-objects", the_repository, 3505 + "loosen_unused_packed_objects/loosened", loosened_objects_nr); 3500 3506 } 3501 3507 3502 3508 /*
+7 -2
builtin/repack.c
··· 20 20 static int pack_kept_objects = -1; 21 21 static int write_bitmaps = -1; 22 22 static int use_delta_islands; 23 - static char *packdir, *packtmp; 23 + static char *packdir, *packtmp_name, *packtmp; 24 24 25 25 static const char *const git_repack_usage[] = { 26 26 N_("git repack [<options>]"), ··· 530 530 } 531 531 532 532 packdir = mkpathdup("%s/pack", get_object_directory()); 533 - packtmp = mkpathdup("%s/.tmp-%d-pack", packdir, (int)getpid()); 533 + packtmp_name = xstrfmt(".tmp-%d-pack", (int)getpid()); 534 + packtmp = mkpathdup("%s/%s", packdir, packtmp_name); 534 535 535 536 sigchain_push_common(remove_pack_on_signal); 536 537 ··· 573 574 repack_promisor_objects(&po_args, &names); 574 575 575 576 if (existing_packs.nr && delete_redundant) { 577 + for_each_string_list_item(item, &names) { 578 + strvec_pushf(&cmd.args, "--keep-pack=%s-%s.pack", 579 + packtmp_name, item->string); 580 + } 576 581 if (unpack_unreachable) { 577 582 strvec_pushf(&cmd.args, 578 583 "--unpack-unreachable=%s",
+4
t/perf/p5600-partial-clone.sh
··· 35 35 git -C bare.git rev-list --all --count --exclude-promisor-objects 36 36 ' 37 37 38 + test_perf 'gc' ' 39 + git -C bare.git gc 40 + ' 41 + 38 42 test_done
+8
t/t5616-partial-clone.sh
··· 548 548 grep "version 2" trace 549 549 ' 550 550 551 + test_expect_success 'repack does not loosen promisor objects' ' 552 + rm -rf client trace && 553 + git clone --bare --filter=blob:none "file://$(pwd)/srv.bare" client && 554 + test_when_finished "rm -rf client trace" && 555 + GIT_TRACE2_PERF="$(pwd)/trace" git -C client repack -A -d && 556 + grep "loosen_unused_packed_objects/loosened:0" trace 557 + ' 558 + 551 559 . "$TEST_DIRECTORY"/lib-httpd.sh 552 560 start_httpd 553 561