Reimagining notmuch-git/nmbug

Subject: Reimagining notmuch-git/nmbug

Date: Wed, 29 Mar 2023 02:41:23 -0600

To: notmuch@notmuchmail.org

Cc:

From: Felipe Contreras


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
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: