diff options
author | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-03-30 17:46:31 +0000 |
---|---|---|
committer | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-03-30 20:49:31 +0000 |
commit | c4aa293b2320feb805c5afeaa373f608e5bc8618 (patch) | |
tree | 08413ea414cbf561d4246b0254d00e899f7ff6b3 /script/public-inbox-convert | |
parent | f1a3ece0df6825792f1ec0ca326998c8915fd80d (diff) | |
download | public-inbox-c4aa293b2320feb805c5afeaa373f608e5bc8618.tar.gz |
Ensure -convert and -compact do not make repositories unreadable on live servers.
Diffstat (limited to 'script/public-inbox-convert')
-rwxr-xr-x | script/public-inbox-convert | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/script/public-inbox-convert b/script/public-inbox-convert index e6fb4f5f..f58bf27b 100755 --- a/script/public-inbox-convert +++ b/script/public-inbox-convert @@ -5,9 +5,10 @@ use strict; use warnings; use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev); use PublicInbox::MIME; -use PublicInbox::Inbox; +use PublicInbox::InboxWritable; use PublicInbox::Config; use PublicInbox::V2Writable; +use PublicInbox::Import; use PublicInbox::Spawn qw(spawn); use Cwd 'abs_path'; my $usage = "Usage: public-inbox-convert OLD NEW\n"; @@ -39,16 +40,28 @@ unless ($old) { }; $old = PublicInbox::Inbox->new($old); } +$old = PublicInbox::InboxWritable->new($old); if (($old->{version} || 1) >= 2) { die "Only conversion from v1 inboxes is supported\n"; } my $new = { %$old }; delete $new->{altid}; # TODO: support altid for v2 -$new->{mainrepo} = $new_dir; +$new->{mainrepo} = abs_path($new_dir); $new->{version} = 2; -$new = PublicInbox::Inbox->new($new); -my $v2w = PublicInbox::V2Writable->new($new, 1); -$v2w->init_inbox($jobs); +$new = PublicInbox::InboxWritable->new($new); +my $v2w; +$old->umask_prepare; +$old->with_umask(sub { + local $ENV{GIT_CONFIG} = "$old->{mainrepo}/config"; + $v2w = PublicInbox::V2Writable->new($new, 1); + $v2w->init_inbox($jobs); + chomp(my $sr = $old->git->qx('config', 'core.sharedRepository')); + if ($sr ne '') { + PublicInbox::Import::run_die(['git', 'config', + "--file=$new->{mainrepo}/all.git/config", + 'core.sharedRepository', $sr]); + } +}); my $state = ''; my ($prev, $from); my $head = $old->{ref_head} || 'HEAD'; |