]> Sergey Matveev's repositories - public-inbox.git/commitdiff
v2: avoid redundant/repeated configs for git partition repos
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Sat, 3 Mar 2018 20:56:15 +0000 (20:56 +0000)
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Sat, 3 Mar 2018 21:02:21 +0000 (21:02 +0000)
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
lib/PublicInbox/V2Writable.pm
t/init.t
t/v2writable.t

index 71469a9566e774c1c56e990e63e868bff110ed44..725bbd838075156f37b982384dd9bb5e077dab0f 100644 (file)
@@ -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";
index 31376db28bc4857b850804756b53f6bd496c2711..461432ea3ffbe695c3fe02f2a5e11b564408cd0f 100644 (file)
@@ -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;
index 54b90ec58415778587dfe164259f76f0d96c4133..6ae608e53ee7f0304647d59c598f59a6e2e55c05 100644 (file)
--- 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();
index bf8ae5e6c563514b5def130ea1b0810a4e06b6aa..2d35aca387d524b145e2fe58844e4a8391778d3d 100644 (file)
@@ -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, @_ };