my $os = $self->{-objstore} // return;
my $fg = $self->{-ent}->{forkgroup} // return;
my $dir = "$os/$fg.git";
- my @cmd = ('git', "--git-dir=$dir", 'config');
- my $opt = +{ map { $_ => $self->{lei}->{$_} } (0..2) };
if (!-d $dir && !$self->{dry_run}) {
PublicInbox::Import::init_bare($dir);
+ my @cmd = ('git', "--git-dir=$dir", 'config');
+ my $opt = { 2 => $self->{lei}->{2} };
for ('repack.useDeltaIslands=true',
'pack.island=refs/remotes/([^/]+)/') {
run_die([@cmd, split(/=/, $_, 2)], undef, $opt);
}
my $key = $self->{-key} // die 'BUG: no -key';
my $rn = substr(sha256_hex($key), 0, 16);
- unless ($self->{dry_run}) {
- # --no-tags is required to avoid conflicts
- for ("url=$uri", "fetch=+refs/*:refs/remotes/$rn/*",
- 'tagopt=--no-tags') {
- my @kv = split(/=/, $_, 2);
- $kv[0] = "remote.$rn.$kv[0]";
- run_die([@cmd, @kv], undef, $opt);
- }
- }
if (!-d $self->{cur_dst} && !$self->{dry_run}) {
my $alt = File::Spec->rel2abs("$dir/objects");
PublicInbox::Import::init_bare($self->{cur_dst});
EOM
close $fh or die "close($f): $!";
}
- bless { %$self, -osdir => $dir, -remote => $rn }, __PACKAGE__;
+ bless {
+ %$self, -osdir => $dir, -remote => $rn, -uri => $uri
+ }, __PACKAGE__;
}
sub fp_done {
sub cmp_fp_fetch {
my ($self, $go_fetch) = @_;
+ # $go_fetch is either resume_fetch or fgrp_enqueue
+ my $new = $self->{-ent}->{fingerprint} // die 'BUG: no fingerprint';
+ my $key = $self->{-key} // die 'BUG: no -key';
+ if (my $cur_ent = $self->{-local_manifest}->{$key}) {
+ # runs go_fetch->DESTROY run if eq
+ return $go_fetch->cancel if $cur_ent->{fingerprint} eq $new;
+ }
my $dst = $self->{cur_dst} // $self->{dst};
my $cmd = ['git', "--git-dir=$dst", 'show-ref'];
my $opt = { 2 => $self->{lei}->{2} };
sub fgrp_enqueue {
my ($self, $fgrp) = @_;
+ my $opt = { 2 => $self->{lei}->{2} };
+ # --no-tags is required to avoid conflicts
+ my $u = $fgrp->{-uri} // die 'BUG: no {-uri}';
+ my $rn = $fgrp->{-remote} // die 'BUG: no {-remote}';
+ my @cmd = ('git', "--git-dir=$fgrp->{-osdir}", 'config');
+ for ("url=$u", "fetch=+refs/*:refs/remotes/$rn/*", 'tagopt=--no-tags') {
+ my @kv = split(/=/, $_, 2);
+ $kv[0] = "remote.$rn.$kv[0]";
+ $self->{dry_run} ? $self->{lei}->qerr("# @cmd @kv") :
+ run_die([@cmd, @kv], undef, $opt);
+ }
push @{$self->{fgrp_todo}->{$fgrp->{-osdir}}}, $fgrp;
}
_write_inbox_config($self);
my $dst = $self->{cur_dst} // $self->{dst};
if (defined(my $o = $self->{-ent} ? $self->{-ent}->{owner} : undef)) {
- run_die([qw(git config -f), "$dst/config", 'gitweb.owner', $o]);
+ my $key = $self->{-key} // die 'BUG: no -key';
+ my $cur = $self->{-local_manifest}->{$key}->{owner} // "\0";
+ $cur eq $o or run_die([qw(git config -f),
+ "$dst/config", 'gitweb.owner', $o]);
}
my $o = "$dst/objects";
if (open(my $fh, '<', my $fn = "$o/info/alternates")) {;
$m;
}
+sub load_current_manifest ($) {
+ my ($self) = @_;
+ my $fn = $self->{-manifest} // return;
+ if (open(my $fh, '<', $fn)) {
+ decode_manifest($fh, $fn, $fn);
+ } elsif ($!{ENOENT}) { # non-fatal, we can just do it slowly
+ warn "open($fn): $!\n";
+ undef;
+ } else {
+ die "open($fn): $!\n";
+ }
+}
+
sub multi_inbox ($$$) {
my ($self, $path, $m) = @_;
my $incl = $self->{lei}->{opt}->{include};
warn $@;
return try_scrape($self);
}
+ local $self->{-local_manifest} = load_current_manifest($self);
my ($path_pfx, $n, $multi) = multi_inbox($self, \$path, $m);
return $lei->child_error(1, $multi) if !ref($multi);
my $v2 = delete $multi->{v2};
$ic =~ /\A(?:v1|v2|always|never)\z/s or die <<"";
--inbox-config must be one of `always', `v2', `v1', or `never'
- if (defined(my $os = $lei->{opt}->{objstore})) {
- $os = 'objstore' if $os eq ''; # --objstore w/o args
- $os = "$self->{dst}/$os" if $os !~ m!\A/!;
- $self->{-objstore} = $os;
+ # we support --objstore= and --manifest= with '' (empty string)
+ for my $default (qw(objstore manifest.js.gz)) {
+ my ($k) = (split(/\./, $default))[0];
+ my $v = $lei->{opt}->{$k} // next;
+ $v = $default if $v eq '';
+ $v = "$self->{dst}/$v" if $v !~ m!\A/!;
+ $self->{"-$k"} = $v;
}
local $LIVE;
my $iv = $lei->{opt}->{'inbox-version'} //