From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) 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.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 08AF01FAFD for ; Tue, 6 Mar 2018 08:42:44 +0000 (UTC) From: "Eric Wong (Contractor, The Linux Foundation)" To: meta@public-inbox.org Subject: [PATCH 26/34] v2: avoid redundant/repeated configs for git partition repos Date: Tue, 6 Mar 2018 08:42:34 +0000 Message-Id: <20180306084242.19988-27-e@80x24.org> In-Reply-To: <20180306084242.19988-1-e@80x24.org> References: <20180306084242.19988-1-e@80x24.org> List-Id: We'll let the config of all.git dictate every other subrepo to ease maintenance and configuration. The "include" directive has been supported since git 1.7.10, so it's safe to depend on as v2 requires git 2.6.0+ anyways for "get-mark" in fast-import. --- lib/PublicInbox/SearchIdx.pm | 2 +- lib/PublicInbox/V2Writable.pm | 10 +++++++--- t/init.t | 2 ++ t/v2writable.t | 16 ++++++++++++++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index 71469a9..725bbd8 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -817,7 +817,7 @@ sub _read_git_config_perm { my ($self) = @_; my @cmd = qw(config); if ($self->{version} == 2) { - push @cmd, "--file=$self->{mainrepo}/inbox-config"; + push @cmd, "--file=$self->{mainrepo}/all.git/config"; } my $fh = $self->{git}->popen(@cmd, 'core.sharedRepository'); local $/ = "\n"; diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index 31376db..461432e 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -244,16 +244,20 @@ sub git_init { die "$git_dir exists\n" if -e $git_dir; my @cmd = (qw(git init --bare -q), $git_dir); PublicInbox::Import::run_die(\@cmd); - @cmd = (qw/git config/, "--file=$git_dir/config", - 'repack.writeBitmaps', 'true'); - PublicInbox::Import::run_die(\@cmd); my $all = "$self->{-inbox}->{mainrepo}/all.git"; unless (-d $all) { @cmd = (qw(git init --bare -q), $all); PublicInbox::Import::run_die(\@cmd); + @cmd = (qw/git config/, "--file=$all/config", + 'repack.writeBitmaps', 'true'); + PublicInbox::Import::run_die(\@cmd); } + @cmd = (qw/git config/, "--file=$git_dir/config", + 'include.path', '../../all.git/config'); + PublicInbox::Import::run_die(\@cmd); + my $alt = "$all/objects/info/alternates"; my $new_obj_dir = "../../git/$new.git/objects"; my %alts; diff --git a/t/init.t b/t/init.t index 54b90ec..6ae608e 100644 --- a/t/init.t +++ b/t/init.t @@ -38,6 +38,8 @@ SKIP: { ok(-d "$tmpdir/v2list", 'v2list directory exists'); ok(-f "$tmpdir/v2list/msgmap.sqlite3", 'msgmap exists'); ok(-d "$tmpdir/v2list/all.git", 'catch-all.git directory exists'); + @cmd = (qw(git config), "--file=$tmpdir/v2list/all.git/config", + qw(core.sharedRepository 0644)); } done_testing(); diff --git a/t/v2writable.t b/t/v2writable.t index bf8ae5e..2d35aca 100644 --- a/t/v2writable.t +++ b/t/v2writable.t @@ -32,6 +32,22 @@ my $mime = PublicInbox::MIME->create( my $im = PublicInbox::V2Writable->new($ibx, 1); ok($im->add($mime), 'ordinary message added'); + +if ('ensure git configs are correct') { + my @cmd = (qw(git config), "--file=$mainrepo/all.git/config", + qw(core.sharedRepository 0644)); + is(system(@cmd), 0, "set sharedRepository in all.git"); + my $git0 = PublicInbox::Git->new("$mainrepo/git/0.git"); + my $fh = $git0->popen(qw(config core.sharedRepository)); + my $v = eval { local $/; <$fh> }; + chomp $v; + is($v, '0644', 'child repo inherited core.sharedRepository'); + $fh = $git0->popen(qw(config --bool repack.writeBitmaps)); + $v = eval { local $/; <$fh> }; + chomp $v; + is($v, 'true', 'child repo inherited repack.writeBitmaps'); +} + { my @warn; local $SIG{__WARN__} = sub { push @warn, @_ }; -- EW