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
This commit is contained in:
@ -3479,6 +3479,7 @@ static void loosen_unused_packed_objects(void)
|
|||||||
{
|
{
|
||||||
struct packed_git *p;
|
struct packed_git *p;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
uint32_t loosened_objects_nr = 0;
|
||||||
struct object_id oid;
|
struct object_id oid;
|
||||||
|
|
||||||
for (p = get_all_packs(the_repository); p; p = p->next) {
|
for (p = get_all_packs(the_repository); p; p = p->next) {
|
||||||
@ -3492,11 +3493,16 @@ static void loosen_unused_packed_objects(void)
|
|||||||
nth_packed_object_id(&oid, p, i);
|
nth_packed_object_id(&oid, p, i);
|
||||||
if (!packlist_find(&to_pack, &oid) &&
|
if (!packlist_find(&to_pack, &oid) &&
|
||||||
!has_sha1_pack_kept_or_nonlocal(&oid) &&
|
!has_sha1_pack_kept_or_nonlocal(&oid) &&
|
||||||
!loosened_object_can_be_discarded(&oid, p->mtime))
|
!loosened_object_can_be_discarded(&oid, p->mtime)) {
|
||||||
if (force_object_loose(&oid, p->mtime))
|
if (force_object_loose(&oid, p->mtime))
|
||||||
die(_("unable to force loose object"));
|
die(_("unable to force loose object"));
|
||||||
|
loosened_objects_nr++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trace2_data_intmax("pack-objects", the_repository,
|
||||||
|
"loosen_unused_packed_objects/loosened", loosened_objects_nr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -20,7 +20,7 @@ static int delta_base_offset = 1;
|
|||||||
static int pack_kept_objects = -1;
|
static int pack_kept_objects = -1;
|
||||||
static int write_bitmaps = -1;
|
static int write_bitmaps = -1;
|
||||||
static int use_delta_islands;
|
static int use_delta_islands;
|
||||||
static char *packdir, *packtmp;
|
static char *packdir, *packtmp_name, *packtmp;
|
||||||
|
|
||||||
static const char *const git_repack_usage[] = {
|
static const char *const git_repack_usage[] = {
|
||||||
N_("git repack [<options>]"),
|
N_("git repack [<options>]"),
|
||||||
@ -530,7 +530,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
|
|||||||
}
|
}
|
||||||
|
|
||||||
packdir = mkpathdup("%s/pack", get_object_directory());
|
packdir = mkpathdup("%s/pack", get_object_directory());
|
||||||
packtmp = mkpathdup("%s/.tmp-%d-pack", packdir, (int)getpid());
|
packtmp_name = xstrfmt(".tmp-%d-pack", (int)getpid());
|
||||||
|
packtmp = mkpathdup("%s/%s", packdir, packtmp_name);
|
||||||
|
|
||||||
sigchain_push_common(remove_pack_on_signal);
|
sigchain_push_common(remove_pack_on_signal);
|
||||||
|
|
||||||
@ -573,6 +574,10 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
|
|||||||
repack_promisor_objects(&po_args, &names);
|
repack_promisor_objects(&po_args, &names);
|
||||||
|
|
||||||
if (existing_packs.nr && delete_redundant) {
|
if (existing_packs.nr && delete_redundant) {
|
||||||
|
for_each_string_list_item(item, &names) {
|
||||||
|
strvec_pushf(&cmd.args, "--keep-pack=%s-%s.pack",
|
||||||
|
packtmp_name, item->string);
|
||||||
|
}
|
||||||
if (unpack_unreachable) {
|
if (unpack_unreachable) {
|
||||||
strvec_pushf(&cmd.args,
|
strvec_pushf(&cmd.args,
|
||||||
"--unpack-unreachable=%s",
|
"--unpack-unreachable=%s",
|
||||||
|
@ -35,4 +35,8 @@ test_perf 'count non-promisor commits' '
|
|||||||
git -C bare.git rev-list --all --count --exclude-promisor-objects
|
git -C bare.git rev-list --all --count --exclude-promisor-objects
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_perf 'gc' '
|
||||||
|
git -C bare.git gc
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
@ -548,6 +548,14 @@ test_expect_success 'fetch from a partial clone, protocol v2' '
|
|||||||
grep "version 2" trace
|
grep "version 2" trace
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'repack does not loosen promisor objects' '
|
||||||
|
rm -rf client trace &&
|
||||||
|
git clone --bare --filter=blob:none "file://$(pwd)/srv.bare" client &&
|
||||||
|
test_when_finished "rm -rf client trace" &&
|
||||||
|
GIT_TRACE2_PERF="$(pwd)/trace" git -C client repack -A -d &&
|
||||||
|
grep "loosen_unused_packed_objects/loosened:0" trace
|
||||||
|
'
|
||||||
|
|
||||||
. "$TEST_DIRECTORY"/lib-httpd.sh
|
. "$TEST_DIRECTORY"/lib-httpd.sh
|
||||||
start_httpd
|
start_httpd
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user