about summary refs log tree commit homepage
path: root/lib/PublicInbox/Git.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-10-25 00:29:25 +0000
committerEric Wong <e@80x24.org>2023-10-25 07:28:31 +0000
commit07f639c9219968a01d5c722424e9c61d3b146014 (patch)
tree90819294795e27bf2ee74893a4e4cabebf05d84b /lib/PublicInbox/Git.pm
parentf81954fe591c6a6358ba528118874313e3920e83 (diff)
downloadpublic-inbox-07f639c9219968a01d5c722424e9c61d3b146014.tar.gz
This is similar to `backtick` but supports all our existing spawn
functionality (chdir, env, rlimit, redirects, etc.).  It also
supports SCALAR ref redirects like run_script in our test suite
for std{in,out,err}.

We can probably use :utf8 by default for these redirects, even.
Diffstat (limited to 'lib/PublicInbox/Git.pm')
-rw-r--r--lib/PublicInbox/Git.pm6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index a460d155..476dcf30 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -69,6 +69,7 @@ sub check_git_exe () {
                 $GIT_VER = eval("v$1") // die "BUG: bad vstring: $1 ($v)";
                 $EXE_ST = $st;
         }
+        $GIT_EXE;
 }
 
 sub git_version {
@@ -422,6 +423,11 @@ sub async_err ($$$$$) {
         $async_warn ? carp($msg) : $self->fail($msg);
 }
 
+sub cmd {
+        my $self = shift;
+        [ $GIT_EXE // check_git_exe(), "--git-dir=$self->{git_dir}", @_ ]
+}
+
 # $git->popen(qw(show f00)); # or
 # $git->popen(qw(show f00), { GIT_CONFIG => ... }, { 2 => ... });
 sub popen {