about summary refs log tree commit homepage
path: root/lib/PublicInbox/Config.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2024-05-09 00:39:01 +0000
committerEric Wong <e@80x24.org>2024-05-09 03:08:01 +0000
commit39c390da4f5793bdd08a3634ca34ed9c9bda0700 (patch)
tree75d879b15388519020222eeff485a479469513ac /lib/PublicInbox/Config.pm
parentcf3df165033bf36631bd890fa2375339cd95c593 (diff)
downloadpublic-inbox-master.tar.gz
Repeatedly checking $PATH for `git' when we need to call it
multiple times in quick succession doesn't seem useful.  So
avoid some expensive stat(2) syscalls to make things less bad
for systems which require expensive CPU vulnerability
mitigations.

This also saves a bunch of memory allocations since we do the
$PATH lookup in pure Perl to avoid doing the uncacheable lookup
in a vfork-ed child.
Diffstat (limited to 'lib/PublicInbox/Config.pm')
-rw-r--r--lib/PublicInbox/Config.pm5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index d6300610..49659a2e 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -13,6 +13,7 @@ use v5.10.1;
 use parent qw(Exporter);
 our @EXPORT_OK = qw(glob2re rel2abs_collapsed);
 use PublicInbox::Inbox;
+use PublicInbox::Git qw(git_exe);
 use PublicInbox::Spawn qw(popen_rd run_qx);
 our $LD_PRELOAD = $ENV{LD_PRELOAD}; # only valid at startup
 our $DEDUPE; # set to {} to dedupe or clear cache
@@ -188,7 +189,7 @@ sub git_config_dump {
                 unshift(@opt_c, '-c', "include.path=$file") if defined($file);
                 tmp_cmd_opt(\%env, $opt);
         }
-        my @cmd = ('git', @opt_c, qw(config -z -l --includes));
+        my @cmd = (git_exe, @opt_c, qw(config -z -l --includes));
         push(@cmd, '-f', $file) if !@opt_c && defined($file);
         my $fh = popen_rd(\@cmd, \%env, $opt);
         my $rv = config_fh_parse($fh, "\0", "\n");
@@ -608,7 +609,7 @@ sub config_cmd {
         my ($self, $env, $opt) = @_;
         my $f = $self->{-f} // default_file();
         my @opt_c = @{$self->{-opt_c} // []};
-        my @cmd = ('git', @opt_c, 'config');
+        my @cmd = (git_exe, @opt_c, 'config');
         @opt_c ? tmp_cmd_opt($env, $opt) : push(@cmd, '-f', $f);
         \@cmd;
 }