]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Import.pm
v1writable: new wrapper which is closer to v2writable
[public-inbox.git] / lib / PublicInbox / Import.pm
index fc4e72dc93ea0ce978a93f5224c74e5b8178acc3..12abf39995ffbcd1677f94be807828449e06c96c 100644 (file)
@@ -18,19 +18,22 @@ use PublicInbox::MDA;
 use POSIX qw(strftime);
 
 sub new {
+       # we can't change arg order, this is documented in POD
+       # and external projects may rely on it:
        my ($class, $git, $name, $email, $ibx) = @_;
        my $ref = 'refs/heads/master';
        if ($ibx) {
                $ref = $ibx->{ref_head} || 'refs/heads/master';
                $name ||= $ibx->{name};
                $email ||= $ibx->{-primary_address};
+               $git ||= $ibx->git;
        }
        bless {
                git => $git,
                ident => "$name <$email>",
                mark => 1,
                ref => $ref,
-               inbox => $ibx,
+               -inbox => $ibx,
                path_type => '2/38', # or 'v2'
                lock_path => "$git->{git_dir}/ssoma.lock", # v2 changes this
                bytes_added => 0,
@@ -178,7 +181,7 @@ sub _update_git_info ($$) {
        run_die([@cmd, 'update-server-info'], undef);
        ($self->{path_type} eq '2/38') and eval {
                require PublicInbox::SearchIdx;
-               my $ibx = $self->{inbox} || $git_dir;
+               my $ibx = $self->{-inbox} || $git_dir;
                my $s = PublicInbox::SearchIdx->new($ibx);
                $s->index_sync({ ref => $self->{ref} });
        };
@@ -433,6 +436,16 @@ sub run_die ($;$$) {
        $? == 0 or die join(' ', @$cmd) . " failed: $?\n";
 }
 
+sub init_bare {
+       my ($dir) = @_;
+       my @cmd = (qw(git init --bare -q), $dir);
+       run_die(\@cmd);
+       # set a reasonable default:
+       @cmd = (qw/git config/, "--file=$dir/config",
+               'repack.writeBitmaps', 'true');
+       run_die(\@cmd);
+}
+
 sub done {
        my ($self) = @_;
        my $w = delete $self->{out} or return;
@@ -586,7 +599,7 @@ __END__
 
 =head1 NAME
 
-PublicInbox::Import - message importer for public-inbox
+PublicInbox::Import - message importer for public-inbox v1 inboxes
 
 =head1 VERSION