use PublicInbox::Inbox;
use PublicInbox::Spawn qw(run_qx);
use PublicInbox::Eml;
+use PublicInbox::Git qw(git_exe);
*rel2abs_collapsed = \&PublicInbox::Config::rel2abs_collapsed;
sub setup_signals {
my $env;
defined($pwd) && substr($cd // '/', 0, 1) ne '/' and
$env->{PWD} = "$pwd/$cd";
- my $cmd = [ qw(git rev-parse --git-dir) ];
+ my $cmd = [ git_exe, qw(rev-parse --git-dir) ];
my $dir = run_qx($cmd, $env, { -C => $cd });
die "error in @$cmd (cwd:${\($cd // '.')}): $?\n" if $?;
chomp $dir;
} elsif (($? >> 8) != 1) {
$urlmatch_broken = 1;
} elsif ($try_git) { # n.b. this takes cwd into account
- $val = run_qx([qw(git config), @bool,
+ $val = run_qx([$cmd->[0], 'config', @bool,
qw(-z --get-urlmatch), $key, $url]);
undef $val if $?;
}
# git-credential wrapper with built-in .netrc fallback
package PublicInbox::GitCredential;
use v5.12;
+use PublicInbox::Git qw(git_exe);
use PublicInbox::Spawn qw(popen_rd);
use autodie qw(close pipe);
sub run ($$;$) {
my ($self, $op, $lei) = @_;
my ($in_r, $in_w, $out_r);
- my $cmd = [ qw(git credential), $op ];
+ my $cmd = [ git_exe, 'credential', $op ];
pipe($in_r, $in_w);
if ($lei) { # we'll die if disconnected:
pipe($out_r, my $out_w);
package PublicInbox::Import;
use v5.12;
use parent qw(PublicInbox::Lock);
+use PublicInbox::Git qw(git_exe);
use PublicInbox::Spawn qw(run_die run_qx spawn);
use PublicInbox::MID qw(mids mid2path);
use PublicInbox::Address;
sub default_branch () {
state $default_branch = do {
- my $h = run_qx([qw(git config --global init.defaultBranch)],
+ my $h = run_qx([git_exe,qw(config --global init.defaultBranch)],
{ GIT_CONFIG => undef });
chomp $h;
$h eq '' ? 'refs/heads/master' : "refs/heads/$h";
use PublicInbox::Spawn qw(run_wait popen_rd run_qx);
use PublicInbox::Lock;
use PublicInbox::Eml;
+use PublicInbox::Git qw(git_exe);
use PublicInbox::Import;
use PublicInbox::ContentHash qw(git_sha);
use PublicInbox::OnDestroy;
# caller needs to "-t $self->{1}" to check if tty
sub start_pager {
my ($self, $new_env) = @_;
- chomp(my $pager = run_qx([qw(git var GIT_PAGER)]));
+ chomp(my $pager = run_qx([git_exe, qw(var GIT_PAGER)]));
warn "`git var PAGER' error: \$?=$?" if $?;
return if $pager eq 'cat' || $pager eq '';
$new_env //= {};
use PublicInbox::Spawn qw(run_wait run_qx which);
use PublicInbox::DS;
use PublicInbox::Eml;
-use PublicInbox::Git;
+use PublicInbox::Git qw(git_exe);
use PublicInbox::IO qw(read_all);
sub get_git_dir ($$) {
my ($lei, $d) = @_;
return $d if -d "$d/objects" && -d "$d/refs" && -e "$d/HEAD";
- my $cmd = [ qw(git rev-parse --git-dir) ];
+ my $cmd = [ git_exe, qw(rev-parse --git-dir) ];
my $opt = { '-C' => $d };
if (defined($lei->{opt}->{cwd})) { # --cwd used, report errors
$opt->{2} = $lei->{2};
package PublicInbox::LeiConfig; # subclassed by LeiEditSearch
use v5.12;
use PublicInbox::PktOp;
+use PublicInbox::Git qw(git_exe);
use Fcntl qw(SEEK_SET);
use autodie qw(open seek);
use PublicInbox::IO qw(read_all);
my ($self, $reason) = @_;
my $lei = $self->{lei};
$lei->pgr_err($reason) if defined $reason;
- my $cmd = [ qw(git config --edit -f), $self->{-f} ];
+ my $cmd = [ git_exe, qw(config --edit -f), $self->{-f} ];
my $env = { GIT_CONFIG => $self->{-f} };
$self->cfg_edit_begin if $self->can('cfg_edit_begin');
# run in script/lei foreground
package PublicInbox::LeiInput;
use v5.12;
use PublicInbox::DS;
+use PublicInbox::Git qw(git_exe);
use PublicInbox::Spawn qw(which popen_rd);
use PublicInbox::InboxWritable qw(eml_from_path);
each_ibx_eml($self, $esrch, @args);
} elsif ($self->{missing_ok} && !-e $input) { # don't ->fail
if ($lei->{cmd} eq 'p2q') {
- my $fp = [ qw(git format-patch --stdout -1), $input ];
+ my $fp = [ git_exe, qw(format-patch --stdout -1),
+ $input ];
my $rdr = { 2 => $lei->{2} };
my $fh = popen_rd($fp, undef, $rdr);
eval { $self->input_fh('eml', $fh, $input, @args) };
use v5.12;
use parent qw(PublicInbox::IPC PublicInbox::LeiInput PublicInbox::MailDiff);
use PublicInbox::Spawn qw(run_wait);
+use PublicInbox::Git qw(git_exe);
require PublicInbox::LeiRediff;
sub diff_a ($$) {
my ($self, $eml) = @_;
my $dir = "$self->{tmp}/N".(++$self->{nr});
$self->dump_eml($dir, $eml);
- my $cmd = [ qw(git diff --no-index) ];
+ my $cmd = [ git_exe, qw(diff --no-index) ];
my $lei = $self->{lei};
PublicInbox::LeiRediff::_lei_diff_prepare($lei, $cmd);
push @$cmd, qw(-- a), "N$self->{nr}";
package PublicInbox::LeiSavedSearch;
use v5.12;
use parent qw(PublicInbox::Lock);
-use PublicInbox::Git;
+use PublicInbox::Git qw(git_exe);
use PublicInbox::OverIdx;
use PublicInbox::LeiSearch;
use PublicInbox::Config;
sub cfg_set { # called by LeiXSearch
my ($self, @args) = @_;
my $lk = $self->lock_for_scope; # git-config doesn't wait
- run_die([qw(git config -f), $self->{'-f'}, @args]);
+ run_die([git_exe, qw(config -f), $self->{'-f'}, @args]);
}
# drop-in for LeiDedupe API
use PublicInbox::Hval;
use PublicInbox::ViewDiff;
use PublicInbox::Spawn qw(popen_rd);
+use PublicInbox::Git qw(git_exe);
use Term::ANSIColor;
use POSIX ();
use PublicInbox::Address;
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); # reuse normal git config
+ my @cmd = (git_exe, qw(config -z --includes -l)); # reuse normal git cfg
my $r = popen_rd(\@cmd, undef, { 2 => $lei->{2} });
my $cfg = PublicInbox::Config::config_fh_parse($r, "\0", "\n");
if (!$r->close) {
use PublicInbox::MsgIter qw(msg_part_text);
use PublicInbox::ViewDiff qw(flush_diff);
use PublicInbox::GitAsyncCat;
+use PublicInbox::Git qw(git_exe);
use PublicInbox::ContentDigestDbg;
use PublicInbox::Qspawn;
use PublicInbox::IO qw(write_file);
my $n = 'N'.(++$self->{nr});
my $dir = "$self->{tmp}/$n";
$self->dump_eml($dir, $eml);
- my $cmd = [ qw(git diff --no-index --no-color -- a), $n ];
+ my $cmd = [ git_exe, qw(diff --no-index --no-color -- a), $n ];
my $opt = { -C => "$self->{tmp}", quiet => 1 };
my $qsp = PublicInbox::Qspawn->new($cmd, undef, $opt);
$qsp->psgi_qx($self->{ctx}->{env}, undef, \&emit_msg_diff, $self);
use v5.10.1;
use PublicInbox::Spawn qw(run_die run_qx);
use PublicInbox::Import;
+use PublicInbox::Git qw(git_exe);
use File::Temp 0.19;
use List::Util qw(max);
use PublicInbox::IO qw(read_all);
my ($self, $epoch_nr) = @_;
my $f = epoch_dir($self)."/$epoch_nr.git/config";
my $v = "../../$self->{all}/config";
+ my @cmd = (git_exe, qw(config -f), $f, 'include.path');
if (-r $f) {
- chomp(my $x = run_qx([qw(git config -f), $f, 'include.path']));
+ chomp(my $x = run_qx(\@cmd));
return if $x eq $v;
}
- run_die([qw(git config -f), $f, 'include.path', $v ]);
+ run_die [@cmd, $v];
}
sub add_epoch {
use URI::Escape qw(uri_escape_utf8);
use File::Spec;
use autodie qw(fcntl open);
+use PublicInbox::Git qw(git_exe);
-my @EACH_REF = (qw(git for-each-ref --sort=-creatordate),
+my @EACH_REF = (git_exe, qw(for-each-ref --sort=-creatordate),
"--format=%(HEAD)%00".join('%00', map { "%($_)" }
qw(objectname refname:short subject creatordate:short)));
my $HEADS_CMD = <<'';
my $qsp_err = \($ctx->{-qsp_err} = '');
my %opt = (quiet => 1, 2 => $ctx->{wcr}->{log_fh});
my %env = (GIT_DIR => $ctx->{git}->{git_dir});
- my @log = (qw(git log), "-$nl", '--pretty=format:%d %H %h %cs %s');
+ my @log = (git_exe, 'log', "-$nl", '--pretty=format:%d %H %h %cs %s');
push(@log, $tip) if defined $tip;
# limit scope for MockHTTP test (t/solver_git.t)