From 430bb4cd5234634741062060ae4e546f80703d56 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 11 Oct 2023 07:20:54 +0000 Subject: import: switch to Unix stream socket for fast-import We use fewer file descriptors and fewer lines of code this way. I'm not aware of any place we rely on POSIX pipe semantics with `git fast-import', and sockets have bigger buffers by default in most cases (even if Linux allows larger pipe buffers). --- script/public-inbox-convert | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'script') diff --git a/script/public-inbox-convert b/script/public-inbox-convert index 780f7194..0cc52777 100755 --- a/script/public-inbox-convert +++ b/script/public-inbox-convert @@ -120,7 +120,7 @@ my $head = $old->{ref_head} || 'HEAD'; my $rd = $old->git->popen(qw(fast-export --use-done-feature), $head); $v2w->idx_init($opt); my $im = $v2w->importer; -my ($r, $w) = $im->gfi_start; +my $io = $im->gfi_start; my $h = '[0-9a-f]'; my %D; my $last; @@ -131,12 +131,12 @@ while (<$rd>) { $state = 'commit'; } elsif (/^data ([0-9]+)/) { my $len = $1; - print $w $_ or $im->wfail; + print $io $_ or $im->wfail; while ($len) { my $n = read($rd, my $tmp, $len) or die "read: $!"; warn "$n != $len\n" if $n != $len; $len -= $n; - print $w $tmp or $im->wfail; + print $io $tmp or $im->wfail; } next; } elsif ($state eq 'commit') { @@ -144,9 +144,9 @@ while (<$rd>) { my ($mark, $path) = ($1, $2); $D{$path} = $mark; if ($last && $last ne 'm') { - print $w "D $last\n" or $im->wfail; + print $io "D $last\n" or $im->wfail; } - print $w "M 100644 :$mark m\n" or $im->wfail; + print $io "M 100644 :$mark m\n" or $im->wfail; $last = 'm'; next; } @@ -154,18 +154,18 @@ while (<$rd>) { my $mark = delete $D{$1}; defined $mark or die "undeleted path: $1\n"; if ($last && $last ne 'd') { - print $w "D $last\n" or $im->wfail; + print $io "D $last\n" or $im->wfail; } - print $w "M 100644 :$mark d\n" or $im->wfail; + print $io "M 100644 :$mark d\n" or $im->wfail; $last = 'd'; next; } } last if $_ eq "done\n"; - print $w $_ or $im->wfail; + print $io $_ or $im->wfail; } close $rd or die "fast-export: \$?=$? \$!=$!\n"; -$r = $w = undef; # v2w->done does the actual close and error checking +$io = undef; $v2w->done; if (my $old_mm = $old->mm) { $old->cleanup; -- cgit v1.2.3-24-ge0c7