]> Sergey Matveev's repositories - public-inbox.git/log
public-inbox.git
3 years agolei: add "lei up" to complement "lei q --save"
Eric Wong [Tue, 13 Apr 2021 10:54:46 +0000 (10:54 +0000)]
lei: add "lei up" to complement "lei q --save"

The command isn't finalized, yet, but it's intended to update
an existing saved search.

3 years agolei q: start wiring up saved search
Eric Wong [Tue, 13 Apr 2021 10:54:45 +0000 (10:54 +0000)]
lei q: start wiring up saved search

This will have a over.sqlite3 for content-based deduplication.
It may exhibit ibxish methods, so serving a read-only (or even
R/W) IMAP or instance or displaying HTML isn't outside the realm
of possibility.

3 years agolei_query: rearrange internals to capture query early
Eric Wong [Tue, 13 Apr 2021 10:54:44 +0000 (10:54 +0000)]
lei_query: rearrange internals to capture query early

To support saved search, we need the query string available to
us before we setup LeiDedupe via (LeiOverview || LeiToMail).

3 years agolei_dedupe: adjust to prepare for saved searches
Eric Wong [Tue, 13 Apr 2021 10:54:43 +0000 (10:54 +0000)]
lei_dedupe: adjust to prepare for saved searches

LeiSavedSearch will use a LeiDedupe-like internal API,
so we won't have to make as many changes to callsites
between saved and unsaved searches.

3 years agolei_xsearch: use per-external queries when not sorting
Eric Wong [Tue, 13 Apr 2021 10:54:42 +0000 (10:54 +0000)]
lei_xsearch: use per-external queries when not sorting

We only need the combined mset query when we care about sort
order.  When writing to --output destinations intended for MUA
consumption, sort order is irrelevant as MUAs are expected to
offer their own sorting, so run queries to each external in
parallel.

This prepares us for docid-sort-based saved search support.

It will also become faster than the combined mset query for
users with many externals due to current Xapian exhibiting poor
performance with many shards (the same reason -extindex exists)

3 years agolei blob: quiet "git rev-parse --git-dir" stderr w/o --cwd
Eric Wong [Mon, 12 Apr 2021 17:32:20 +0000 (17:32 +0000)]
lei blob: quiet "git rev-parse --git-dir" stderr w/o --cwd

This seemed to be causing occasional "make check-run" failures
with errors bleeding into other tests.

3 years agowww: do not obfuscate addresses in URLs
Eric Wong [Sun, 11 Apr 2021 05:32:55 +0000 (05:32 +0000)]
www: do not obfuscate addresses in URLs

As they are likely Message-IDs.   If an email address ends up in
a URL, then it's likely public, so there's even less reason to
obfuscate that particular address.

[km: add xt/perf-obfuscate.t]
[ew: modernize perf test (5.10.1), use diag instead of print]

This version of the patch avoids the massive slowdown noted by Kyle in
<https://public-inbox.org/meta/87wnt9or6t.fsf@kyleam.com/>.
Performance remains roughly the same, if not slightly faster
(which may be due to me testing this on a busy server).  Results
from xt/perf-obfuscate.t against 6078 messages on a local mirror
of <https://public-inbox.org/meta/>:

before: 6.67 usr + 0.04 sys = 6.71 CPU
 after: 6.64 usr + 0.04 sys = 6.68 CPU

Reported-by: Kyle Meyer <kyle@kyleam.com>
Helped-by: Kyle Meyer <kyle@kyleam.com>
Link: https://public-inbox.org/meta/87a6q8p5qa.fsf@kyleam.com/
3 years agoimport: convert init.defaultBranch to fully qualified ref
Kyle Meyer [Wed, 7 Apr 2021 23:05:24 +0000 (19:05 -0400)]
import: convert init.defaultBranch to fully qualified ref

init.defaultBranch expects a branch name, not a fully qualified ref.
git-init prepends "refs/heads/" automatically and unconditionally.

PublicInbox::Import::default_branch, however, incorrectly passes on
the init.defaultBranch value as is, leading to it being used in spots
where a fully qualified ref is required.  For example, with an
init.defaultBranch value of "master", public-inbox-index for a v2
repository would lead to an all.git repository where HEAD's content is
"ref: master" instead of "ref: refs/heads/master".

Prepend "refs/heads/" to the incoming init.defaultBranch value.

Fixes: 7c2f36de2fb49dd7 (import: respect init.defaultBranch)
3 years agolei_store: use getpwuid and hostname for ident
Eric Wong [Mon, 5 Apr 2021 20:38:13 +0000 (20:38 +0000)]
lei_store: use getpwuid and hostname for ident

It's nicer in case a user transfers lei/store across machines
and wants a way to track when/where they imported something.

3 years agoscript/lei: waitpid for git-credential and pager
Eric Wong [Mon, 5 Apr 2021 08:36:57 +0000 (08:36 +0000)]
script/lei: waitpid for git-credential and pager

We need to ensure we reap things we spawn.

3 years agolei q: fix auth IMAP --output with remote mboxrd
Eric Wong [Mon, 5 Apr 2021 10:27:52 +0000 (10:27 +0000)]
lei q: fix auth IMAP --output with remote mboxrd

IMAP authentication info is only shared amongst lei2mail workers,
so we must ensure all IMAP writes go through lei2mail workers
even if we don't have to access the mail through git.

This allows us to decouple the latency of the remote mboxrd from
the latency of the IMAP --output at the expense of extra IPC
overhead within our own processes.

3 years agolei_to_mail: improve comments and reduce LoC
Eric Wong [Mon, 5 Apr 2021 10:27:51 +0000 (10:27 +0000)]
lei_to_mail: improve comments and reduce LoC

We don't need to waste LoC on corner cases, single-use internal
subs, or restoring SIG{__WARN__} when a process exits.  All that
extra code contributes to memory use and startup time, especially
for users who can't use FD passing.

3 years agolei: maildir: move shard support to MdirReader
Eric Wong [Mon, 5 Apr 2021 10:27:50 +0000 (10:27 +0000)]
lei: maildir: move shard support to MdirReader

We'll eventually want lei_input users like "lei import" and
"lei tag" to support parallel reads.

3 years agolei_tag: fix comments w.r.t support levels
Eric Wong [Mon, 5 Apr 2021 10:27:49 +0000 (10:27 +0000)]
lei_tag: fix comments w.r.t support levels

RFC 8621 registers $flagged, $answered, $seen, $draft which
map to IMAP, Maildir, and mbox Status/X-Status flags.

$forwarded is noted in JMAP, but only Maildir and and the
"Lemonade" IMAP profile (RFC 5550) support it

3 years agolei_to_mail: trim down imports
Eric Wong [Mon, 5 Apr 2021 10:27:48 +0000 (10:27 +0000)]
lei_to_mail: trim down imports

We don't need to import so many things.  None of the Errno
constants are in common paths so unlikely to benefit from
constant folding.

3 years agolei_search: ignore Resent-Message-ID for indexing
Eric Wong [Sun, 4 Apr 2021 17:38:07 +0000 (22:38 +0500)]
lei_search: ignore Resent-Message-ID for indexing

It currently conflicts with the way OverIdx and SearchIdx
index messages, ultimately leading to violating a NOT NULL
constraint on id2num.id in over.sqlite3.

We may allow searching Resent-* fields separately, though I'm
not sure how useful it'll be.

3 years agolei/store: (more) synchronous non-fatal error output
Eric Wong [Sat, 3 Apr 2021 10:48:27 +0000 (10:48 +0000)]
lei/store: (more) synchronous non-fatal error output

Since every command that writes to lei/store calls ->done
to commit its output, we can rely on that to return a
pathname for a readable file with errors in it.

Errors can still get crossed up if multiple lei commands
are writing to the store at once, but reduces the delay
in seeing them and ensures it won't get seen when somebody
is attempting to use shell completion.

3 years agolei: improve handling of Message-ID-less draft messages
Eric Wong [Sat, 3 Apr 2021 10:48:26 +0000 (10:48 +0000)]
lei: improve handling of Message-ID-less draft messages

We need a stable fallback time for digest2mid in the presence
of messages without Received/Date headers.  Furthermore, we
must avoid using uninitialized smsg->{mid} when parsing
References for draft replies.

3 years agolei tag: note message mismatches on failure
Eric Wong [Sat, 3 Apr 2021 10:48:25 +0000 (10:48 +0000)]
lei tag: note message mismatches on failure

Just exiting with a failure code and no error message is
confusing :x

3 years agotest_common: lei_ok: improve diagnostics
Eric Wong [Sat, 3 Apr 2021 10:48:24 +0000 (10:48 +0000)]
test_common: lei_ok: improve diagnostics

$? is useful, as is labeling lei_err since I'm easily-confused :x

3 years agolei_store: update alternates on new epoch
Eric Wong [Sat, 3 Apr 2021 10:48:23 +0000 (10:48 +0000)]
lei_store: update alternates on new epoch

We'll just let the ExtSearchIdx code handle this uncommon case
by doing a full commit.

3 years agolei: allow progress to non-TTY after MUA spawn
Eric Wong [Sat, 3 Apr 2021 01:37:33 +0000 (22:37 -0300)]
lei: allow progress to non-TTY after MUA spawn

Sometimes I want to save debug info to a file or pipe even when
spawning an MUA.

3 years agolei q: don't show remote progress if MUA is running
Eric Wong [Sat, 3 Apr 2021 01:37:32 +0000 (22:37 -0300)]
lei q: don't show remote progress if MUA is running

Remote results can safely use the same mset progress reporting
as local results, despite not knowing the size of the result
set.  We're assuming terminal MUAs, for now.

3 years agoxt/lei-auth-fail: test more failure cases
Eric Wong [Sat, 3 Apr 2021 02:24:27 +0000 (02:24 +0000)]
xt/lei-auth-fail: test more failure cases

Because failures are often overlooked, unfortunately.

3 years agonet_reader: fix read-only "lei convert" auth failures
Eric Wong [Sat, 3 Apr 2021 02:24:26 +0000 (02:24 +0000)]
net_reader: fix read-only "lei convert" auth failures

"convert" is actually a bit more complicated than "lei import"
since it may need auth for either input or output.

3 years agolei_auth: rename {net_merge} to {net_merge_continue}
Eric Wong [Sat, 3 Apr 2021 02:24:25 +0000 (02:24 +0000)]
lei_auth: rename {net_merge} to {net_merge_continue}

No reason for the hash key to differ from the subroutine
name, here.

3 years agolei tag: fix tagging of IMAP inputs
Eric Wong [Sat, 3 Apr 2021 02:24:24 +0000 (02:24 +0000)]
lei tag: fix tagging of IMAP inputs

We need net_merge_all and to lock the number of worker jobs.
Parallel inputs are not supported, yet (is it needed?, I don't
expect this to be used for multiple files very often...).

3 years agolei q: ensure wq workers shutdown on IMAP auth failures
Eric Wong [Sat, 3 Apr 2021 02:24:23 +0000 (02:24 +0000)]
lei q: ensure wq workers shutdown on IMAP auth failures

Leaving workers running on after auth failures is bad and messy,
cleanup our process management to have consistent worker
teardowns.  Improve error reporting, too, instead of letting
Mail::IMAPClient->exists fail due to undef.

3 years agoURInntps: add URI 5.08 release note
Eric Wong [Sat, 3 Apr 2021 02:24:22 +0000 (02:24 +0000)]
URInntps: add URI 5.08 release note

I wanted to say 2031, but that's probably too aggressive a
removal timeline.

3 years agolei: fix git-credential handling
Eric Wong [Fri, 2 Apr 2021 09:42:54 +0000 (05:42 -0400)]
lei: fix git-credential handling

I completely forgot about git-credential prompting when
making lei background the client process for MUA.

Now it backgrounds itself only for the MUA when no FDs are
passed, since the MUA is the final command run.  Otherwise, it
relies on FD passing as before.

Fixes: c790a75439f3a1db ("script/lei: background ourselves on MUA/pager exec")
3 years agolei: maildir: handle "forwarded" keyword as "P"
Eric Wong [Thu, 1 Apr 2021 10:12:19 +0000 (10:12 +0000)]
lei: maildir: handle "forwarded" keyword as "P"

mbox and IMAP seem to have no way of describing this keyword.
but Maildir does with the "P" flagged (for "passed").

3 years agolei_store: quiet down per-message related warnings
Eric Wong [Thu, 1 Apr 2021 12:10:42 +0000 (17:10 +0500)]
lei_store: quiet down per-message related warnings

It's needless noise when doing augment and output preparation
and shows up way too late and out-of-band with lei-daemon.

3 years agolei_store: quiet down git user info being unset
Eric Wong [Thu, 1 Apr 2021 12:10:41 +0000 (17:10 +0500)]
lei_store: quiet down git user info being unset

lei_store contents aren't intended to become public, so there's
no point in nagging users for their email address for git
committer information like git does.

3 years agolei_store: set_xvmd: don't add if no vmd at all
Eric Wong [Thu, 1 Apr 2021 12:10:40 +0000 (17:10 +0500)]
lei_store: set_xvmd: don't add if no vmd at all

There's no point in adding vmd information for an external
message if it was never stored and there's no vmd at all.

We also don't need to check _docids_for for similar messages,
either, since we always check lse->kw_changed, first.

3 years agolei q: reduce lei/store work for kw changes to stored mail
Eric Wong [Thu, 1 Apr 2021 12:10:39 +0000 (17:10 +0500)]
lei q: reduce lei/store work for kw changes to stored mail

We can tweak lse->kw_changed to return docids and reduce IPC
traffic and reduce work the lei/store worker needs to do.

3 years agolei_query: remove unnecessary V2Writable require
Eric Wong [Thu, 1 Apr 2021 12:10:38 +0000 (17:10 +0500)]
lei_query: remove unnecessary V2Writable require

AFAIK that was only used for nproc detection, and nproc
is handled by PublicInbox::IPC, nowadays.

3 years agolei sucks: sub-command to aid bug reporting
Eric Wong [Thu, 1 Apr 2021 09:32:38 +0000 (02:32 -0700)]
lei sucks: sub-command to aid bug reporting

It's a bit of an Easter egg, though it's not possible to hide those
in Free Software...  Anyways, it doesn't cost us an entry in %CMD
of LEI.pm and anybody frustrated enough with lei just might type
"lei sucks" on the command-line :>

3 years agobuild: generate PublicInbox.pm with $VERSION
Eric Wong [Thu, 1 Apr 2021 09:32:37 +0000 (02:32 -0700)]
build: generate PublicInbox.pm with $VERSION

Thanks to git-describe, we can generate and update this
file to aid users in bug reporting.

3 years agoscript/lei: background ourselves on MUA/pager exec
Eric Wong [Wed, 31 Mar 2021 23:29:36 +0000 (23:29 +0000)]
script/lei: background ourselves on MUA/pager exec

This ought to give the MUA or pager exclusive access to the
controlling terminal.  The downside is we can only exec the
pager or MUA once per invocation, but I can't imagine a valid
case for running those things multiple times, either.

Note: I'm no expert when it comes to terminal control matters,
but this allows Ctrl-Z-ed mutt instance to come back and is
a nice code reduction, as well.

3 years agolei_input: reduce IPC traffic with multiple inputs
Eric Wong [Wed, 31 Mar 2021 07:45:51 +0000 (07:45 +0000)]
lei_input: reduce IPC traffic with multiple inputs

No point in sending a command for every input when a
single one will do.  We'll also trigger LeiStore->done
sooner in the worker rather than later.

3 years agolei blob: "--mail" disables solver, use --include/only
Eric Wong [Wed, 31 Mar 2021 01:53:18 +0000 (06:53 +0500)]
lei blob: "--mail" disables solver, use --include/only

Assume a user specifying --mail doesn't want to spend cycles
reconstructing a blob from a code repo.  Also, don't require
users to use add-external or a previous -I or --only to ready an
external for use with ale.git.

3 years agodoc: lei-overview: favor Maildir for mutt examples
Eric Wong [Wed, 31 Mar 2021 00:41:09 +0000 (00:41 +0000)]
doc: lei-overview: favor Maildir for mutt examples

mboxes are generally horrible for interactive read-write use due
to locking.  Describe our parallel behavior with mutt, since
writing mail can take a long while and being able to read
results as they're written is nice.

We'll also use a gzipped mboxrd for the import example, since
we can decompress gzipped mboxrds automatically, now.

3 years agodoc: add lei-mail-formats(5) manpage
Eric Wong [Wed, 31 Mar 2021 00:41:08 +0000 (00:41 +0000)]
doc: add lei-mail-formats(5) manpage

While plenty of online documentation exists, it's good to have
a locally-available summary for users to look at offline.
Fix a URL in Watch.pm while we're at it, too.

3 years agolei: fix IMAP auth failure handling
Eric Wong [Tue, 30 Mar 2021 22:29:47 +0000 (03:29 +0500)]
lei: fix IMAP auth failure handling

We must use the $ops hashref returned by lei->workers_start,
since it's modified to include extra handlers for auth failures
and whatnot.

Fixes: 954581b8e575966a ("lei: simplify PktOp callers")
3 years agolei tag: rename from "lei mark"
Eric Wong [Tue, 30 Mar 2021 09:39:27 +0000 (09:39 +0000)]
lei tag: rename from "lei mark"

I've decided "tag" is a better verb since it seems more
widely-used term for associating metadata with data.

Not only is it analogous to the "notmuch tag" command, but
also makes sense when compared to tooling for manipulating
metadata for non-mail data (e.g. audio metadata tags).

There's even a Wikipedia entry for it:
https://en.wikipedia.org/wiki/Tag_(metadata)
whereas "mark" is used in the description, but has no
entry of its own with regards to metadata.

3 years agolei q: avoid redundant default setting for sort with l2m
Eric Wong [Tue, 30 Mar 2021 09:10:55 +0000 (09:10 +0000)]
lei q: avoid redundant default setting for sort with l2m

No point in munging user-supplied $lei->{opt} when %mset_opt
exists.  We'll be depending on docid being in descending order
for saved search support.

3 years agolei_to_mail: update some comments and style
Eric Wong [Tue, 30 Mar 2021 07:23:54 +0000 (12:23 +0500)]
lei_to_mail: update some comments and style

Note that update_kw_maybe is critical in preventing accidental
data loss with default "lei q --output" behavior.

Also avoid treating (proposed) MH support as lock-free, since
appears to lack specifications for locking and be even worse
than mbox* in that regard...

3 years agogit: local_nick: handle trailing or redundant '/' in git_dir
Eric Wong [Mon, 29 Mar 2021 23:58:54 +0000 (23:58 +0000)]
git: local_nick: handle trailing or redundant '/' in git_dir

Some cgit configs use trailing slashes in pathnames
which we preserve internally.

Before this change, trailing slashes in cgit config files
was causing ViewVCS (SolverGit) output to show up as "???"
for coderepos without cgitUrl configured.

3 years agolei_input: support compressed mboxes
Eric Wong [Mon, 29 Mar 2021 17:49:42 +0000 (17:49 +0000)]
lei_input: support compressed mboxes

Since "lei q" and "lei convert" already support writing these
compressed inboxes, it makes sense that all mbox readers support
them, as well.

Using compression is one reliable way to know an mboxrd or mboxo
hasn't been unexpectedly truncated.

3 years agolei blob: cleanup solver tmpdir on failure
Eric Wong [Mon, 29 Mar 2021 17:47:17 +0000 (17:47 +0000)]
lei blob: cleanup solver tmpdir on failure

$lei->fail sends SIGTERM which prevents the File::Temp::Dir in
$solver->{tmp} from being cleaned up, so use $lei->child_error
instead.

3 years agolei_input: treat ".eml" and ".patch" suffix as "eml"
Eric Wong [Mon, 29 Mar 2021 07:08:25 +0000 (07:08 +0000)]
lei_input: treat ".eml" and ".patch" suffix as "eml"

".eml" is a suffix supported by (/usr/local)/etc/mime.types
on Debian and FreeBSD systems using the "mime-support" package.
".patch" is what "git format-patch" generates by default since
git v1.5.0 in 2007.

3 years agolei: use IO::Uncompress::Gunzip MultiStream
Eric Wong [Mon, 29 Mar 2021 07:08:24 +0000 (07:08 +0000)]
lei: use IO::Uncompress::Gunzip MultiStream

This is compatible with default gunzip(1) behavior and
future-proofs us against potential changes in PublicInbox::WWW
to save memory on public-inbox-httpd instances.

3 years agolei_input: avoid special case sub for --stdin
Eric Wong [Mon, 29 Mar 2021 07:08:23 +0000 (07:08 +0000)]
lei_input: avoid special case sub for --stdin

We can consistently open /dev/stdin correctly nowadays, so
drop the input_stdin and just use the normal ->path_to_fd
code path.

3 years agodoc: lei: update description, add warnings
Eric Wong [Mon, 29 Mar 2021 08:04:16 +0000 (08:04 +0000)]
doc: lei: update description, add warnings

Describing the design details and architecture doesn't seem
appropriate for a section 1 manpage.

We'll also add a warning about it being in the early stages.

3 years agodoc: lei q: clarify default output as stdout
Eric Wong [Mon, 29 Mar 2021 08:04:15 +0000 (08:04 +0000)]
doc: lei q: clarify default output as stdout

Seeing a plain "-" may be confusing, especially when we also
support it for --stdin.  Use the C<> POD directive to denote it
as code, too.

3 years agodoc: lei q: add warning for --output clobbering
Eric Wong [Mon, 29 Mar 2021 08:04:14 +0000 (08:04 +0000)]
doc: lei q: add warning for --output clobbering

The behavior matching mairix still frightens me a bit when it
comes to supporting new users.  On the other hand, I've rarely
ever used --augment with mairix, so I still think the current
(dangerous) behavior makes sense in the context of search results.

3 years agodoc: lei q: drop NNTP from --output description
Eric Wong [Mon, 29 Mar 2021 08:04:13 +0000 (08:04 +0000)]
doc: lei q: drop NNTP from --output description

We only support NNTP as inputs for convert, import, and
mark|tag.  I'm not sure if supporting NNTP output is worth
it, nor do we have a good way to test it.

3 years agot/epoll: explicitly use scalar operator for @events
Eric Wong [Mon, 29 Mar 2021 05:19:03 +0000 (05:19 +0000)]
t/epoll: explicitly use scalar operator for @events

It's slightly easier to test on a machine without Test::More
and I'm hand-rolling my own is() and ok() subs.

3 years agodoc config: don't render a to-do comment
Kyle Meyer [Mon, 29 Mar 2021 03:13:43 +0000 (23:13 -0400)]
doc config: don't render a to-do comment

In the public-inbox-config manpage, the match=domain item under
publicinbox.wwwlisting has a to-do comment that gets rendered as
"support showing cgit listing".  That's potential confusing to
readers, especially given that the "TODO" is dropped.

Change the markup so that the comment isn't rendered.

3 years agodoc lei overview: better explain routes into local store
Kyle Meyer [Mon, 29 Mar 2021 03:11:17 +0000 (23:11 -0400)]
doc lei overview: better explain routes into local store

3 years agodoc lei overview: note that lei-init is usually unnecessary
Kyle Meyer [Mon, 29 Mar 2021 03:11:16 +0000 (23:11 -0400)]
doc lei overview: note that lei-init is usually unnecessary

cf. https://public-inbox.org/meta/20210325083207.GA30551@dcvr

3 years agodoc lei: add manpages for new commands
Kyle Meyer [Mon, 29 Mar 2021 03:11:15 +0000 (23:11 -0400)]
doc lei: add manpages for new commands

3 years agodoc lei: update manpages with new options
Kyle Meyer [Mon, 29 Mar 2021 03:11:14 +0000 (23:11 -0400)]
doc lei: update manpages with new options

3 years agodoc lei: don't render most to-do comments
Kyle Meyer [Mon, 29 Mar 2021 03:11:13 +0000 (23:11 -0400)]
doc lei: don't render most to-do comments

The lei manpages have a number of to-dos, but with the exception of
the lei-q's -tt warning, none of them seem worth displaying to the
reader (and some might not be worth addressing at all).

3 years agodoc lei: drop an unnecessary to-do comment
Kyle Meyer [Mon, 29 Mar 2021 03:11:12 +0000 (23:11 -0400)]
doc lei: drop an unnecessary to-do comment

When a new command is implemented, it is probably clear that it should
be added to lei.pod, but either way, having a to-do comment in lei.pod
isn't likely to help.

3 years agodoc lei: note --stdin shortcut in synopses
Kyle Meyer [Mon, 29 Mar 2021 03:11:11 +0000 (23:11 -0400)]
doc lei: note --stdin shortcut in synopses

3 years agodoc lei-q: fix typo in -tt description
Kyle Meyer [Mon, 29 Mar 2021 03:11:10 +0000 (23:11 -0400)]
doc lei-q: fix typo in -tt description

3 years agotreewide: shorten temporary filename
Eric Wong [Sun, 28 Mar 2021 09:01:24 +0000 (09:01 +0000)]
treewide: shorten temporary filename

File::Temp only requires four 'X' characters (unlike mkstemp(3),
which requires six).  So only so only give it 4 to avoid an
80-column violation and maybe save metadata space on FSes.

3 years agolei: drop coderepo placeholders, submodule TODO
Eric Wong [Sun, 28 Mar 2021 09:01:23 +0000 (09:01 +0000)]
lei: drop coderepo placeholders, submodule TODO

"lei blob" supports --git-dir and -C, and checks if the
current directory has a git directory associated with it.
It will likely support submodules in the future.

I'm inclined to believe declaring coderepos in a command-line
tool is needless clutter and users will rarely want to search
for blobs across different projects when on the command-line.

3 years agolei blob: add remote external support
Eric Wong [Sun, 28 Mar 2021 09:01:22 +0000 (09:01 +0000)]
lei blob: add remote external support

Introduce a new LeiRemote wrapper to provide an internal API
which SolverGit expects.  This lets us use HTTP/HTTPS endpoints
to reconstruct blobs off patches as we would with local
endpoints, just more slowly...

3 years agot/lei_store: ensure LeiSearch responds to ->isrch
Eric Wong [Sun, 28 Mar 2021 09:01:21 +0000 (09:01 +0000)]
t/lei_store: ensure LeiSearch responds to ->isrch

This is needed for SolverGit, at least, and maybe other
bits we share with PSGI in lei.

3 years agolei blob: flesh out help text
Eric Wong [Sun, 28 Mar 2021 09:01:20 +0000 (09:01 +0000)]
lei blob: flesh out help text

This means "lei blob" gets shell completion, too.

3 years agolei help: show "NAME=VALUE" properly for -c
Eric Wong [Sun, 28 Mar 2021 09:01:19 +0000 (09:01 +0000)]
lei help: show "NAME=VALUE" properly for -c

3 years agolei blob: some extra tests
Eric Wong [Sun, 28 Mar 2021 09:01:18 +0000 (09:01 +0000)]
lei blob: some extra tests

Most of it already gets tested since most of the logic is in
SolverGit, but make sure it's all wired up properly to lei.

3 years agolei blob: fail early if no git dirs
Eric Wong [Sun, 28 Mar 2021 09:01:17 +0000 (09:01 +0000)]
lei blob: fail early if no git dirs

This avoids triggering a "BUG:" message in the solver code.

3 years agolei blob: support --no-mail switch
Eric Wong [Sun, 28 Mar 2021 09:01:16 +0000 (09:01 +0000)]
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.

3 years agolei blob: dclose if already failed
Eric Wong [Sun, 28 Mar 2021 09:01:15 +0000 (09:01 +0000)]
lei blob: dclose if already failed

We must close the socket to trigger pager exit if blob
reconstruction fails.  Not sure how to test this in the
test suite...

3 years agolei init: split out into separate file
Eric Wong [Sun, 28 Mar 2021 09:01:14 +0000 (09:01 +0000)]
lei init: split out into separate file

This is a rarely-needed command, so keep it separate file
so it's easier-to-find and maybe saves a bit of RAM.

3 years agolei: simplify PktOp callers
Eric Wong [Sun, 28 Mar 2021 09:01:13 +0000 (09:01 +0000)]
lei: simplify PktOp callers

Provide a consistent ->op_wait_event method instead of
forcing callers to loop (or not) at each callsite.
This also avoid a leak possibility by avoiding circular
references.

3 years agotest_common: require_mods bundles
Eric Wong [Sun, 28 Mar 2021 00:17:25 +0000 (00:17 +0000)]
test_common: require_mods bundles

This makes it easier to manage test dependencies on systems
where optional stuff isn't installed.  This fixes some lei tests
which didn't check for Plack before starting -httpd, and ensures
Parse::RecDescent is available for -imapd in case
Mail::IMAPClient stops using it.

3 years agolei mark: relax label requirements
Eric Wong [Sat, 27 Mar 2021 23:22:38 +0000 (23:22 +0000)]
lei mark: relax label requirements

It seems safe to use ALLCAPS labels like "INBOX" with Xapian.
We'll also allow single-character labels.

3 years agolei blob: aka "git-show-harder" for blobs
Eric Wong [Sat, 27 Mar 2021 11:45:51 +0000 (11:45 +0000)]
lei blob: aka "git-show-harder" for blobs

This implements blob reconstruction via SolverGit,
emulating the functionality of /$INBOX/$OID/s/ endpoint
in PublicInbox::WWW.

It uses the current working tree as a coderepo, and
accepts any number of --git-dir=$PATH args.

Remote externals are not yet supported.

v2: use absolute path for git repos

3 years agolei_query: hoist out lxs_prepare
Eric Wong [Sat, 27 Mar 2021 11:45:50 +0000 (11:45 +0000)]
lei_query: hoist out lxs_prepare

We'll be reusing it for "lei blob", as it makes sense
to keep handling of --only, --include, etc. switches
consistent.

3 years agolei help: move "lei help" into LeiHelp.pm
Eric Wong [Sat, 27 Mar 2021 11:45:49 +0000 (11:45 +0000)]
lei help: move "lei help" into LeiHelp.pm

We need to load LeiHelp.pm anyways if somebody calls "lei help",
so save a few kB RAM for users who don't need help.

3 years agolei_ale: do not create store unnecessarily
Eric Wong [Sat, 27 Mar 2021 11:45:48 +0000 (11:45 +0000)]
lei_ale: do not create store unnecessarily

We want to be able to read blobs without writing anything to
disk.

3 years agolei mark: disallow '!' in labels
Eric Wong [Fri, 26 Mar 2021 09:51:26 +0000 (09:51 +0000)]
lei mark: disallow '!' in labels

'!' could wreak havoc if exposed to a shell like bash.  It seems
like a rare character for use in file/directory/mailbox names.

3 years agolei: support /dev/fd/[0-2] inputs and outputs in daemon
Eric Wong [Fri, 26 Mar 2021 09:51:25 +0000 (09:51 +0000)]
lei: support /dev/fd/[0-2] inputs and outputs in daemon

Since lei-daemon won't have the same FDs as the client, we
need to special-case thse mappings and won't be able to open
arbitrary, non-standard FDs.

We also won't attempt to support /proc/self/fd/[0-2] since
that's a Linux-ism.  /dev/fd/[0-2] and /dev/std{in,out,err}
are portable to FreeBSD, at least.  mawk(1) also supports
/dev/std{out,err}, as does gawk(1) (which supports everything
we can support, and arbitrary /dev/fd/$FD).

3 years agolei: do not blindly commit to lei/store on close
Eric Wong [Fri, 26 Mar 2021 09:51:24 +0000 (09:51 +0000)]
lei: do not blindly commit to lei/store on close

It may hide errors/bugs, instead do it explicitly for each
worker that writes to it.  For lei_xsearch, it will be better
to close before spawning the MUA for future use since we may
need it again once the user starts changing keywords.

3 years agolei q: skip lei/store->write_prepare for JSON outputs
Eric Wong [Fri, 26 Mar 2021 09:51:23 +0000 (09:51 +0000)]
lei q: skip lei/store->write_prepare for JSON outputs

JSON outputs won't write to lei/store at all, so there's
no point in forking the store worker if it's not already
running.

LeiSearch object ($lse) is also fork-safe until it opens a
persistent FD for Xapian/SQLite so we can unconditionally
carry it across fork.

3 years agogit-send-email-reply: Append subject
Stavros Ntentos [Fri, 26 Mar 2021 16:31:46 +0000 (18:31 +0200)]
git-send-email-reply: Append subject

I keep copy-pasting the addresses provided,
I keep writing my plaintext reply in a file,
and I keep forgetting to add a subject
(because I am "just" writing a plaintext file)

Teach `git-send-email-reply` to append a `--subject` line.

[ew: avoid URI-encoded subject on command-line, adjust t/reply.t]

Signed-off-by: Stavros Ntentos <133706+stdedos@users.noreply.github.com>
3 years agolei: add some labels support
Eric Wong [Fri, 26 Mar 2021 04:29:37 +0000 (06:29 +0200)]
lei: add some labels support

"lei q" now displays labels in JSON output, "lei mark"
can add or remove labels for any messages.

"lei ls-label" is supported, too.

Unfortunately, "lei q" won't hande "kw:" or "L:" for
external messages, they must be imported, first.

3 years agolei: _lei_store: use default even if unconfigured
Eric Wong [Fri, 26 Mar 2021 04:29:36 +0000 (06:29 +0200)]
lei: _lei_store: use default even if unconfigured

Perhaps leistore.dir doesn't need to have a config file
entry if we're using the default location.

v2: "account for unconfigured leistore.dir" (on reuse)

3 years agolei_xsearch: wait for kw updates for non-threaded case, too
Eric Wong [Fri, 26 Mar 2021 04:29:35 +0000 (06:29 +0200)]
lei_xsearch: wait for kw updates for non-threaded case, too

We'll also hoist wait_startq out of the per-message loops
since it's not worth having to check every single message
when filling in smsg info is reasonably fast, anyways.

3 years agot/lei: add more diagnostics for failures
Eric Wong [Thu, 25 Mar 2021 04:20:26 +0000 (06:20 +0200)]
t/lei: add more diagnostics for failures

This seems to error out while looping the test suite and
I'm not 100% sure why.

3 years agot/cmd_ipc: workaround signal handling raciness
Eric Wong [Thu, 25 Mar 2021 04:20:25 +0000 (06:20 +0200)]
t/cmd_ipc: workaround signal handling raciness

Perl can't check for interrupts when inside a blocking syscall,
as there's no self-pipe mechanism inside Perl itself.  So fork
a child and have it repeated kill(2) instead of relying on alarm(3).

3 years agolei import: force store, improve test diagnostics
Eric Wong [Thu, 25 Mar 2021 04:20:24 +0000 (06:20 +0200)]
lei import: force store, improve test diagnostics

"lei import" should never be without a {sto}, and *_done should
not be called multiple times, so ensure we can fail if it's
missing.

Update some existing tests to complain loudly by introducing a
handy "xbail" function which wraps "explain" and BAIL_OUT.
BAIL_OUT was painful to type and concatenating the result of
"explain" doesn't work as I thought it would since "explain"
always returns an array, and BAIL_OUT only accepts a single
scalar arg (unlike "die").

3 years agotests: "check-run" uses persistent lei daemon
Eric Wong [Thu, 25 Mar 2021 04:20:23 +0000 (06:20 +0200)]
tests: "check-run" uses persistent lei daemon

We'll use a lei-daemon if it's already running and
TEST_LEI_DAEMON_PERSIST_DIR is set, but we can also start
one and manage it from t/run.perl

This drops "make check-run TEST_LEI_DAEMON_ONLY=1"
time by ~10% for me.

3 years agot/*: drop unnecessary v1-specific index calls
Eric Wong [Thu, 25 Mar 2021 04:20:22 +0000 (06:20 +0200)]
t/*: drop unnecessary v1-specific index calls

Outside of mirrors, we can -init with indexlevel to avoid
calling -index explicitly.

3 years agolei_mirror: don't show success on failure
Eric Wong [Thu, 25 Mar 2021 04:20:21 +0000 (06:20 +0200)]
lei_mirror: don't show success on failure

While we were exiting with a error code, showing a successful
"# mirrored $URL" message is misleading and wrong.  Don't show
success until everything is complete and the config is written.

3 years agolei add-external: do not initialize writable store
Eric Wong [Thu, 25 Mar 2021 04:20:20 +0000 (06:20 +0200)]
lei add-external: do not initialize writable store

There's no need to create or write lei/store when adding
an external, we just need to write to the config file.