]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
git: use run_qx to read `git --version'
authorEric Wong <e@80x24.org>
Fri, 27 Oct 2023 22:21:10 +0000 (22:21 +0000)
committerEric Wong <e@80x24.org>
Sat, 28 Oct 2023 09:08:16 +0000 (09:08 +0000)
It exists, now, so save us a few lines of code.

lib/PublicInbox/Git.pm

index f4a24f2a3c39ddac260bc1a1b7486e9b56d86b16..b5adc1f4a53b5057e6d4a846853ac011b5a091fd 100644 (file)
@@ -18,7 +18,7 @@ use Errno qw(EINTR EAGAIN);
 use File::Glob qw(bsd_glob GLOB_NOSORT);
 use File::Spec ();
 use Time::HiRes qw(stat);
-use PublicInbox::Spawn qw(spawn popen_rd which);
+use PublicInbox::Spawn qw(spawn popen_rd run_qx which);
 use PublicInbox::ProcessIONBF;
 use PublicInbox::Tmpfile;
 use IO::Poll qw(POLLIN);
@@ -61,9 +61,8 @@ sub check_git_exe () {
        my @st = stat($GIT_EXE) or die "stat($GIT_EXE): $!";
        my $st = pack('dd', $st[10], $st[7]);
        if ($st ne $EXE_ST) {
-               my $rd = popen_rd([ $GIT_EXE, '--version' ]);
-               my $v = readline($rd);
-               CORE::close($rd) or die "$GIT_EXE --version: $?";
+               my $v = run_qx([ $GIT_EXE, '--version' ]);
+               die "$GIT_EXE --version: \$?=$?" if $?;
                $v =~ /\b([0-9]+(?:\.[0-9]+){2})/ or die
                        "$GIT_EXE --version output: $v # unparseable";
                $GIT_VER = eval("v$1") // die "BUG: bad vstring: $1 ($v)";