unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Reimagining notmuch-git/nmbug
@ 2023-03-29  8:41 Felipe Contreras
  2023-03-29  9:50 ` Michael J Gruber
  2023-04-03  9:49 ` David Bremner
  0 siblings, 2 replies; 17+ messages in thread
From: Felipe Contreras @ 2023-03-29  8:41 UTC (permalink / raw)
  To: notmuch@notmuchmail.org

Hi,

I noticed you promoted notmuch-git as a user tool to toy around with it.

Very quickly I realized that most of what it does is something I've
been working on for at least 10 years: making git work with other
tools.

I presume you haven't heard of git remote-helpers [1], because they do
precisely what notmuch-git is trying to do.

As a proof of concept I created a remote helper for notmuch [2]. If
you have this script (`git-remote-nm`) anywhere in your path, git will
interpret URLs prefixed with "nm::" as notmuch transports, and you can
do:

  git clone nm::$HOME/mail

The contents of this repository are generated by `git-remote-nm`,
which I chose to write in Ruby, but you can use any language you want.
All it needs to do is interpret simple commands, and generate output
understandable by `git fast-import` [3].

For example, this command actually creates a repository:

  git fast-import <<EOF
  blob
  mark :1
  data 13
  inbox
  unread

  commit refs/heads/master
  mark :2
  committer Author <author@example.com> 1680077472 +0000
  data 0
  M 100644 :1 878we4qdqf.fsf@yoom.home.cworth.org/tags

  EOF

You can interact with this repository as you would with any other
repository, because it is a git repository.

The only difference is at the time of pull/push from this nm remote,
at which time `git-remote-hg` is invoked again.

When you do `git pull` the local tags will be updated with the tags of
the notmuch database.

And when you do `git push` the tags of the notmuch database are
updated with the local tags.

The code that does this is extremely simple, only 180 lines of code.

I wrote some tests using the notmuch default corpus and the last epoch
of the git.git public-inbox and everything works fine. The initial
clone of 28082 messages takes 1.5s and weighs 5.9M on my machine.

Of course, it's only a proof of concept and has very basic features,
but I'm certain the most important features of `notmuch-git` can be
easily implemented.

I see most of the complexity of `notmuch-git` is dealing with caches
and git indexes, but that's a task better left for the tools that were
meant to deal with that: `git fast-import`.

Thoughts?

[1] https://git-scm.com/docs/gitremote-helpers
[2] https://github.com/felipec/git-notmuch
[3] https://git-scm.com/docs/git-fast-import

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2023-04-06 13:50 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-29  8:41 Reimagining notmuch-git/nmbug Felipe Contreras
2023-03-29  9:50 ` Michael J Gruber
2023-03-29 12:17   ` Felipe Contreras
2023-04-03  9:49 ` David Bremner
2023-04-03 10:46   ` David Bremner
2023-04-04  0:47     ` Felipe Contreras
2023-04-04 17:42       ` David Bremner
2023-04-03 11:48   ` Felipe Contreras
2023-04-03 16:01   ` Felipe Contreras
2023-04-03 18:42     ` David Bremner
2023-04-03 19:40       ` David Bremner
2023-04-03 20:23         ` Felipe Contreras
2023-04-03 23:37           ` David Bremner
2023-04-04  0:29             ` Felipe Contreras
2023-04-04 17:54               ` David Bremner
2023-04-05 16:08                 ` Felipe Contreras
2023-04-06 13:50                   ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).