about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiInput.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-05-05 10:46:37 +0000
committerEric Wong <e@80x24.org>2021-05-05 17:45:16 +0000
commitcf0c7ce3ce81b5c33cb149a7edc3efd99631a57d (patch)
tree1515dfb085ca091d8ce951fc64b9efc652300607 /lib/PublicInbox/LeiInput.pm
parent40f3f2a2c805fc37c7ed35a60948856bd962b493 (diff)
downloadpublic-inbox-cf0c7ce3ce81b5c33cb149a7edc3efd99631a57d.tar.gz
Sometimes a mailed patch is generated with non-ideal output,
(lacking context, noisy whitespace changes, etc.), or a user
wants to use the same external diff viewer they've configured
git to use.

Since we have SolverGit to regenerate arbitrary blobs from
patches; this new command allows us to regenerate a diff with
different options using the blobs SolverGit gives us.

The amount of git-diff(1) options is mind numbing, so it's
likely I missed some favorites or botched the getopt spec
translation.

This also fixes Inbox::base_url to check psgi.url_scheme
before attempting to generate URLs and avoid uninitialized
variable warnings.  Oddly, the "lei blob" tests did not
trigger these uninitialized warnings.

Note: this will automatically import+index the message(s)
it's regenerating, because solver relies on being able
to lookup pre/postimage OIDs and read blobs.
Diffstat (limited to 'lib/PublicInbox/LeiInput.pm')
-rw-r--r--lib/PublicInbox/LeiInput.pm6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/PublicInbox/LeiInput.pm b/lib/PublicInbox/LeiInput.pm
index 46eea111..87083564 100644
--- a/lib/PublicInbox/LeiInput.pm
+++ b/lib/PublicInbox/LeiInput.pm
@@ -69,6 +69,12 @@ error reading $name: $!
                 # but no Content-Length or "From " escaping.
                 # "git format-patch" also generates such files by default.
                 $buf =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s;
+
+                # a user may feed just a body: git diff | lei rediff -U9
+                if ($self->{-force_eml}) {
+                        my $eml = PublicInbox::Eml->new($buf);
+                        substr($buf, 0, 0) = "\n\n" if !$eml->{bdy};
+                }
                 $self->input_eml_cb(PublicInbox::Eml->new(\$buf), @args);
         } else {
                 # prepare_inputs already validated $ifmt