From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 66A5B1FA00 for ; Tue, 9 Feb 2021 08:09:38 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 04/11] git: ->qx: respect caller's $/ in array context Date: Tue, 9 Feb 2021 07:09:30 -0100 Message-Id: <20210209080937.4678-5-e@80x24.org> In-Reply-To: <20210209080937.4678-1-e@80x24.org> References: <20210209080937.4678-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 | 1 - lib/PublicInbox/Import.pm | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index ac7ff267..e176921c 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -364,7 +364,6 @@ sub popen { sub qx { my $fh = popen(@_); if (wantarray) { - local $/ = "\n"; my @ret = <$fh>; close $fh; # caller should check $? @ret; diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm index a070aa1e..e803ee74 100644 --- a/lib/PublicInbox/Import.pm +++ b/lib/PublicInbox/Import.pm @@ -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),