]> Sergey Matveev's repositories - public-inbox.git/commitdiff
git: ->qx: respect caller's $/ in array context
authorEric Wong <e@80x24.org>
Tue, 9 Feb 2021 08:09:30 +0000 (07:09 -0100)
committerEric Wong <e@80x24.org>
Wed, 10 Feb 2021 06:59:03 +0000 (06:59 +0000)
This could lead to bad results when doing ls-tree -z
for v2 import in case there's multiple files.  In any case,
the `local $/ = "\0"' in Import.pm is also eliminated to
reduce potential confusion and surprises.

lib/PublicInbox/Git.pm
lib/PublicInbox/Import.pm

index ac7ff267a1033cb8bbc8234f8ad0b381ff23c94f..e176921c74439ee2c6e2a4b6e6e11cfb313f2874 100644 (file)
@@ -364,7 +364,6 @@ sub popen {
 sub qx {
        my $fh = popen(@_);
        if (wantarray) {
-               local $/ = "\n";
                my @ret = <$fh>;
                close $fh; # caller should check $?
                @ret;
index a070aa1e9be0f6969d09eb1111fd5494b8320b5b..e803ee74c2b8d06c11e7361ef0f32a5d5fd1363e 100644 (file)
@@ -68,11 +68,9 @@ sub gfi_start {
                chomp($self->{tip} = $git->qx(qw(rev-parse --revs-only), $ref));
                die "fatal: rev-parse --revs-only $ref: \$?=$?" if $?;
                if ($self->{path_type} ne '2/38' && $self->{tip}) {
-                       local $/ = "\0";
-                       my @t = $git->qx(qw(ls-tree -r -z --name-only), $ref);
+                       my $t = $git->qx(qw(ls-tree -r -z --name-only), $ref);
                        die "fatal: ls-tree -r -z --name-only $ref: \$?=$?" if $?;
-                       chomp @t;
-                       $self->{-tree} = { map { $_ => 1 } @t };
+                       $self->{-tree} = { map { $_ => 1 } split(/\0/, $t) };
                }
                $in_r = $self->{in} = $git->popen(qw(fast-import
                                        --quiet --done --date-format=raw),