diff options
author | Eric Wong <e@80x24.org> | 2022-11-28 05:31:46 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-11-28 23:38:56 +0000 |
commit | a7f5a512269b31df73aa3716ed3ea014a1839bac (patch) | |
tree | 50c8a20b32a99baf44269a2c1012f0215af5e7be /lib/PublicInbox | |
parent | 3c499dbc312a7cd32da4664a3cfad6500ab98e8d (diff) | |
download | public-inbox-a7f5a512269b31df73aa3716ed3ea014a1839bac.tar.gz |
Unlike object packing, ref packing is cheap and fast.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/LeiMirror.pm | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index 2f96058a..3fea4c29 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -336,16 +336,21 @@ sub fgrp_update { } } +sub pack_refs { + my ($self, $git_dir) = @_; + do_reap($self); + my $cmd = [ 'git', "--git-dir=$git_dir", qw(pack-refs --all --prune) ]; + $self->{lei}->qerr("# @$cmd"); + my $opt = { 1 => $self->{lei}->{1}, 2 => $self->{lei}->{2} }; + $LIVE->{spawn($cmd, undef, $opt)} = [ \&reap_cmd, $self, $cmd ]; +} + sub fgrp_fetched { my ($fgrp) = @_; return if $fgrp->{dry_run} || !$LIVE; my $rn = $fgrp->{-remote}; my %opt = map { $_ => $fgrp->{lei}->{$_} } (0..2); - my $cmd = [ 'git', "--git-dir=$fgrp->{-osdir}", - qw(pack-refs --all --prune) ]; - do_reap($fgrp); - $fgrp->{lei}->qerr("# @$cmd"); - $LIVE->{spawn($cmd, undef, \%opt)} = [ \&reap_cmd, $fgrp, $cmd ]; + pack_refs($fgrp, $fgrp->{-osdir}); # objstore refs always packed $update_ref_stdin or return fgrp_update_old($fgrp); @@ -407,6 +412,7 @@ sub forkgroup_prep { $kv[0] = "remote.$rn.$kv[0]"; run_die([@cmd, @kv], undef, $opt); } + $self->{-do_pack_refs} = 1; # likely coderepo if (!-d $self->{cur_dst}) { my $alt = File::Spec->rel2abs("$dir/objects"); PublicInbox::Import::init_bare($self->{cur_dst}); @@ -573,6 +579,7 @@ sub v1_done { # called via OnDestroy die "rename($f, $o/info/alternates): $!"; $f->unlink_on_destroy(0); } + pack_refs($self, $dst) if delete $self->{-do_pack_refs}; return if ($self->{-is_epoch} || $self->{lei}->{opt}->{'inbox-config'} ne 'always'); write_makefile($dst, 1); |