sub fgrp_update_old ($) { # for git <1.8.5
my ($fgrp) = @_;
- my $cmd = [ 'git', "--git-dir=$fgrp->{cur_dst}",
+ my $cmd = [ @{$fgrp->{-torsocks}}, 'git', "--git-dir=$fgrp->{cur_dst}",
fetch_args($fgrp->{lei}, my $opt = {}) ];
$fgrp->{lei}->qerr("# @$cmd");
do_reap($fgrp);
}
}
+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);
}
sub fgrp_fetch {
- my ($fgrp, $pfx, $fini) = @_;
- my $cmd = [ @$pfx, 'git', "--git-dir=$fgrp->{-osdir}",
+ my ($fgrp, $fini) = @_;
+ my $cmd = [ @{$fgrp->{-torsocks}}, 'git', "--git-dir=$fgrp->{-osdir}",
fetch_args($fgrp->{lei}, my $opt = {}),
$fgrp->{-remote} ];
$fgrp->{-fini} = $fini;
$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});
my $uri = URI->new($self->{cur_src} // $self->{src});
defined($lei->{opt}->{epoch}) and
die "$uri is a v1 inbox, --epoch is not supported\n";
- my $pfx = $curl->torsocks($lei, $uri) or return;
+ $self->{-torsocks} //= $curl->torsocks($lei, $uri) or return;
my $dst = $self->{cur_dst} // $self->{dst};
my $fini = PublicInbox::OnDestroy->new($$, \&v1_done, $self);
- my $cmd = [ @$pfx, clone_cmd($lei, my $opt = {}), "$uri", $dst ];
+ my $cmd = [ @{$self->{-torsocks}}, clone_cmd($lei, my $opt = {}),
+ "$uri", $dst ];
my $fgrp = forkgroup_prep($self, $uri);
if (!defined($fgrp) && defined($self->{-ent})) {
if (defined(my $ref = $self->{-ent}->{reference})) {
push @$cmd, '--reference', "$self->{dst}$ref";
}
}
- $fgrp ? fgrp_fetch($fgrp, $pfx, $fini) :
+ $fgrp ? fgrp_fetch($fgrp, $fini) :
start_clone($self, $cmd, $opt, $fini);
if (!$self->{-is_epoch} && $lei->{opt}->{'inbox-config'} =~
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);
my $lei = $self->{lei};
my $curl = $self->{curl} //= PublicInbox::LeiCurl->new($lei) or return;
my $first_uri = (map { $_->[0] } values %$v2_epochs)[0];
- my $pfx = $curl->torsocks($lei, $first_uri) or return;
+ $self->{-torsocks} //= $curl->torsocks($lei, $first_uri) or return;
my $dst = $self->{cur_dst} // $self->{dst};
my $want = parse_epochs($lei->{opt}->{epoch}, $v2_epochs);
my $task = $m ? bless { %$self }, __PACKAGE__ : $self;
if (defined(my $os = $lei->{opt}->{objstore})) {
$os = 'objstore' if $os eq ''; # --objstore w/o args
- $self->{-objstore} = "$self->{dst}/$os";
+ $os = "$self->{dst}/$os" if $os !~ m!\A/!;
+ $self->{-objstore} = $os;
}
local $LIVE;
my $iv = $lei->{opt}->{'inbox-version'} //