about summary refs log tree commit homepage
path: root/script
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-10-11 07:20:54 +0000
committerEric Wong <e@80x24.org>2023-10-11 22:10:49 +0000
commit430bb4cd5234634741062060ae4e546f80703d56 (patch)
tree4bbe6f69a9dbe1317faaa698195e5df9714e90aa /script
parent770d8b3f465db89d80922c32d766b022cf4b31ed (diff)
downloadpublic-inbox-430bb4cd5234634741062060ae4e546f80703d56.tar.gz
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).
Diffstat (limited to 'script')
-rwxr-xr-xscript/public-inbox-convert18
1 files changed, 9 insertions, 9 deletions
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;