From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 64274202BB for ; Fri, 8 Mar 2019 22:52:19 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/2] v2writable: hoist out fill_alternates Date: Fri, 8 Mar 2019 22:52:16 +0000 Message-Id: <20190308225217.31766-2-e@80x24.org> In-Reply-To: <20190308225217.31766-1-e@80x24.org> References: <20190308225217.31766-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We'll be using this sub to fill $GIT_DIR/objects/info/alternates if somebody uses clone --mirror, too --- lib/PublicInbox/V2Writable.pm | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index b1d8095..bc31ffa 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -509,14 +509,12 @@ sub done { $self->{-inbox}->git->cleanup; } -sub git_init { +sub fill_alternates ($$) { my ($self, $epoch) = @_; - my $pfx = "$self->{-inbox}->{mainrepo}/git"; - my $git_dir = "$pfx/$epoch.git"; - my @cmd = (qw(git init --bare -q), $git_dir); - PublicInbox::Import::run_die(\@cmd); + my $pfx = "$self->{-inbox}->{mainrepo}/git"; my $all = "$self->{-inbox}->{mainrepo}/all.git"; + my @cmd; unless (-d $all) { @cmd = (qw(git init --bare -q), $all); PublicInbox::Import::run_die(\@cmd); @@ -524,8 +522,7 @@ sub git_init { 'repack.writeBitmaps', 'true'); PublicInbox::Import::run_die(\@cmd); } - - @cmd = (qw/git config/, "--file=$git_dir/config", + @cmd = (qw/git config/, "--file=$pfx/$epoch.git/config", 'include.path', '../../all.git/config'); PublicInbox::Import::run_die(\@cmd); @@ -540,12 +537,20 @@ sub git_init { my $dir = "../../git/$i.git/objects"; push @add, $dir if !$alts{$dir} && -d "$pfx/$i.git"; } - return $git_dir unless @add; + return unless @add; open my $fh, '>>', $alt or die "open >> $alt: $!\n"; foreach my $dir (@add) { print $fh "$dir\n" or die "print >> $alt: $!\n"; } close $fh or die "close $alt: $!\n"; +} + +sub git_init { + my ($self, $epoch) = @_; + my $git_dir = "$self->{-inbox}->{mainrepo}/git/$epoch.git"; + my @cmd = (qw(git init --bare -q), $git_dir); + PublicInbox::Import::run_die(\@cmd); + fill_alternates($self, $epoch); $git_dir } -- EW