]> Sergey Matveev's repositories - public-inbox.git/commitdiff
respect umask if core.sharedRepository is not set
authorEric Wong <e@80x24.org>
Wed, 30 May 2018 02:54:48 +0000 (02:54 +0000)
committerEric Wong <e@80x24.org>
Wed, 30 May 2018 20:34:23 +0000 (20:34 +0000)
This is consistent with git itself and the previous behavior
was a result of misunderstanding of how git interprets this.
And adjust tests slightly to match the new behavior.

Reported-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
<38873789-ab42-65a1-20c9-12c30b171f4f@linuxfoundation.org>

lib/PublicInbox/InboxWritable.pm
t/search.t
t/v2writable.t

index 5c11a36c27631e4b82bed1de1dabe222e41ef484..9b0cdfd04e229ce7cb9cce70008f67cded1e028f 100644 (file)
@@ -175,7 +175,7 @@ sub _read_git_config_perm {
 sub _git_config_perm {
        my $self = shift;
        my $perm = scalar @_ ? $_[0] : _read_git_config_perm($self);
-       return PERM_GROUP if (!defined($perm) || $perm eq '');
+       return PERM_UMASK if (!defined($perm) || $perm eq '');
        return PERM_UMASK if ($perm eq 'umask');
        return PERM_GROUP if ($perm eq 'group');
        if ($perm =~ /\A(?:all|world|everybody)\z/) {
index 9a90fd5384e7817c122615d2162aea89d949c488..c971fe3ca5c72f3490c83d844dc7f42a74065950 100644 (file)
@@ -11,7 +11,7 @@ my $tmpdir = tempdir('pi-search-XXXXXX', TMPDIR => 1, CLEANUP => 1);
 my $git_dir = "$tmpdir/a.git";
 my ($root_id, $last_id);
 
-is(0, system(qw(git init -q --bare), $git_dir), "git init (main)");
+is(0, system(qw(git init --shared -q --bare), $git_dir), "git init (main)");
 eval { PublicInbox::Search->new($git_dir) };
 ok($@, "exception raised on non-existent DB");
 
@@ -422,11 +422,12 @@ $ibx->with_umask(sub {
 });
 
 foreach my $f ("$git_dir/public-inbox/msgmap.sqlite3",
+               "$git_dir/public-inbox",
                glob("$git_dir/public-inbox/xapian*/"),
                glob("$git_dir/public-inbox/xapian*/*")) {
        my @st = stat($f);
        my ($bn) = (split(m!/!, $f))[-1];
-       is($st[2] & 07777, -f _ ? 0660 : 0770,
+       is($st[2] & 07777, -f _ ? 0660 : 02770,
                "sharedRepository respected for $bn");
 }
 
index 00b08e0367d5adcb4431a16e0b43c41f3eb721d8..9e3bb755d9c233e7e90a5d2f22aa6278d71d95f5 100644 (file)
@@ -11,6 +11,7 @@ foreach my $mod (qw(DBD::SQLite Search::Xapian)) {
        plan skip_all => "$mod missing for nntpd.t" if $@;
 }
 use_ok 'PublicInbox::V2Writable';
+umask 007;
 my $mainrepo = tempdir('pi-v2writable-XXXXXX', TMPDIR => 1, CLEANUP => 1);
 my $ibx = {
        mainrepo => $mainrepo,