]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
lei view_text: used tied ProcessPipe for `git config'
authorEric Wong <e@80x24.org>
Sun, 24 Sep 2023 05:42:10 +0000 (05:42 +0000)
committerEric Wong <e@80x24.org>
Sun, 24 Sep 2023 18:56:06 +0000 (18:56 +0000)
The code exists and is loaded anyways, so we might as well
save an explicit call to waitpid.  Noticed while checking
over our uses of `git config'

lib/PublicInbox/LeiViewText.pm

index 53555467d12301dbba583415d4b2ef637e506ab9..704418671fda013fde2dee339223b577e7f9236b 100644 (file)
@@ -72,12 +72,11 @@ sub new {
        my $self = bless { %{$lei->{opt}}, -colored => \&uncolored }, $cls;
        $self->{-quote_reply} = 1 if $fmt eq 'reply';
        return $self unless $self->{color} //= -t $lei->{1};
-       my $cmd = [ qw(git config -z --includes -l) ];
-       my ($r, $pid) = popen_rd($cmd, undef, { 2 => $lei->{2} });
+       my @cmd = qw(git config -z --includes -l); # reuse normal git config
+       my $r = popen_rd(\@cmd, undef, { 2 => $lei->{2} });
        my $cfg = PublicInbox::Config::config_fh_parse($r, "\0", "\n");
-       waitpid($pid, 0);
-       if ($?) {
-               warn "# git-config failed, no color (non-fatal)\n";
+       if (!close($r)) {
+               warn "# @cmd failed, no color (non-fatal \$?=$?)\n";
                return $self;
        }
        $self->{-colored} = \&my_colored;