From 73e17de5421d83bedbf84209585cf2408b9af1ce Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 28 Mar 2021 09:01:16 +0000 Subject: lei blob: support --no-mail switch It's possible for a abbreviated OID to be resolved unambiguously to an email before we attempt to look at externals via xsearch; so provide a way for a user to force searching coderepos. If hints (--oid-a, --path-a, --path-b) are present, we'll assume --no-mail by default, otherwise we'll assume the user wants to look through mail for a matching blob. --- lib/PublicInbox/LeiBlob.pm | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'lib/PublicInbox/LeiBlob.pm') diff --git a/lib/PublicInbox/LeiBlob.pm b/lib/PublicInbox/LeiBlob.pm index 9b4c4f30..4bd86253 100644 --- a/lib/PublicInbox/LeiBlob.pm +++ b/lib/PublicInbox/LeiBlob.pm @@ -8,7 +8,6 @@ use v5.10.1; use parent qw(PublicInbox::IPC); use PublicInbox::Spawn qw(spawn popen_rd); use PublicInbox::DS; -use PublicInbox::Eml; sub sol_done_wait { # dwaitpid callback my ($arg, $pid) = @_; @@ -85,18 +84,22 @@ sub do_solve_blob { # via wq_do sub lei_blob { my ($lei, $blob) = @_; $lei->start_pager if -t $lei->{1}; + my $opt = $lei->{opt}; + my $has_hints = grep(defined, @$opt{qw(oid-a path-a path-b)}); - # first, see if it's a blob returned by "lei q" JSON output: - my $rdr = { 1 => $lei->{1} }; - open $rdr->{2}, '>', '/dev/null' or die "open: $!"; - my $cmd = [ 'git', '--git-dir='.$lei->ale->git->{git_dir}, - 'cat-file', 'blob', $blob ]; - waitpid(spawn($cmd, $lei->{env}, $rdr), 0); - return if $? == 0; + # first, see if it's a blob returned by "lei q" JSON output:k + if ($opt->{mail} // ($has_hints ? 0 : 1)) { + my $rdr = { 1 => $lei->{1} }; + open $rdr->{2}, '>', '/dev/null' or die "open: $!"; + my $cmd = [ 'git', '--git-dir='.$lei->ale->git->{git_dir}, + 'cat-file', 'blob', $blob ]; + waitpid(spawn($cmd, $lei->{env}, $rdr), 0); + return if $? == 0; + } # maybe it's a non-email (code) blob from a coderepo - my $git_dirs = $lei->{opt}->{'git-dir'} //= []; - if ($lei->{opt}->{'cwd'} //= 1) { + my $git_dirs = $opt->{'git-dir'} //= []; + if ($opt->{'cwd'} // 1) { my $cgd = get_git_dir('.'); unshift(@$git_dirs, $cgd) if defined $cgd; } -- cgit v1.2.3-24-ge0c7