Commit graph

24 commits

Author SHA1 Message Date
David Bremner
30740296e7 CLI/git: add reset command
Sometimes merging is not what we want with tags; in particular it
tends to keep tags in the local repo that have been removed elsewhere.
This commit provides a new reset command; the reset itself is trivial,
but the work is to provide a safety check that uses the existing
--force and git.safe_fraction machinery.
2024-07-25 17:39:50 +09:00
Jakub Wilk
2f0320c5f2 CLI/git: remove no-op format() call 2024-01-14 08:55:20 -04:00
Jakub Wilk
e310df7093 CLI/git: fix name error 2024-01-14 08:55:06 -04:00
Jakub Wilk
5f3e5dd411 CLI/git: remove unused import
shutil was used only for the tempfile.TemporaryDirectory backport,
which was removed in commit b7c31f6581 ("CLI/git: drop support for
python < 3.2").
2024-01-14 08:54:39 -04:00
David Bremner
891af1d457 CLI/git: use --exclude=false when calling notmuch-search
We use notmuch search in two places in notmuch-git.py: to find which
tags have a given prefix, and to see if message with given id exists
locally. In both cases we do not want the presence of exclude tags
(e.g. deleted) to change the results.
2022-12-27 11:54:57 -04:00
David Bremner
f599b8873f CLI/git: opportunistically use bindings to check for known messages
If the bindings are installed, use them to avoid one exec of notmuch
search per message.
2022-07-16 20:27:40 -04:00
David Bremner
bd4347499f CLI/git: current cache contents of index
Rather than shelling out once per message to get the list of files
corresponding to tags, it is much faster (although potentially a bit
memory intensive) to read them all at once.
2022-07-16 20:27:40 -04:00
David Bremner
bf5eacbe7e CLI/git: add --format-version argument to init subcommand
This is primarily intended to support testing upward compatibility
with legacy repos.
2022-07-07 07:05:55 -03:00
David Bremner
6219e7380a CL/git: add format version 1
The original nmbug format (now called version 0) creates 1
subdirectory of 'tags/' per message. This causes problems for more
than (roughly) 100k messages.

Version 1 introduces 2 layers of hashed directories. This scheme was
chose to balance the number of subdirectories with the number of extra
directories (and git objects) created via hashing.

This should be upward compatible in the sense that old repositories
will continue to work with the updated notmuch-git.
2022-07-07 06:56:05 -03:00
David Bremner
b07e121923 CLI/git: replace most mentions of nmbug
Particularly in help messages, nmbug is confusing for users who may
have never heard of it.
2022-07-07 06:11:04 -03:00
David Bremner
7d1e5a5348 CLI/git: add safety checks for checkout and commit
Commits or checkouts that modify a large fraction of the messages in
the database should be relatively rare (and in some automated process,
probably non-existent). For initial setup, where such operations are
expected, the user can pass --force.
2022-06-17 08:40:19 -03:00
David Bremner
99e85823c8 CLI/git: support configuration for repo location / prefix
This is probably more convenient than always passing a command line
argument.

Use notmuch-config for consistency with other notmuch CLI tools.

Now that there is something relevant in the config files, test the
--config option.
2022-06-17 08:40:19 -03:00
David Bremner
8ed68c1bbe CLI/git: change defaults for repo and prefix
The previous defaults were not suitable for personal (i.e. not
bugtracking for notmuch development) use.

Provide two ways for the user to select nmbug compatible defaults;
command line argument and checking the name of the script.
2022-06-17 08:40:19 -03:00
David Bremner
66ccf420c2 CLI/git: cache git indices
If the private index file matches a previously known revision of the
database, we can update the index incrementally using the recorded
lastmod counter. This is typically much faster than a full update,
although it could be slower in the case of large changes to the
database.

The "git-read-tree HEAD" is also a bottleneck, but unfortunately
sometimes is needed. Cache the index checksum and hash to reduce the
number of times the operation is run. The overall design is a
simplified version of the PrivateIndex class.
2022-06-17 08:40:19 -03:00
David Bremner
5ef56fe812 CLI/git: add @timed decorator, time a few functions
Perf will show which binaries are using the CPU cycles, and standard
python profilers will show which python functions, but neither is
great at finding which call to an external binary is taking time, or
locating I/O hotspots.
2022-06-17 08:40:19 -03:00
David Bremner
f67d7c9e7a CLI/git: replace enumeration of tags with sexp query.
Unlike the (current) infix query parser provided by Xapian, the
notmuch specific sexp query parser supports prefixed wildcard queries,
so use those. In addition to being somewhat faster, this avoids
needing to escape all of the user's tags to pass via the shell.
2022-06-17 08:40:19 -03:00
David Bremner
d4d5737165 CLI/git: suppress warnings about initial branch name
The canonical nmbug repository still uses "master" as the main branch
name, so defer any potential switch away from that name.
2022-06-17 08:40:19 -03:00
David Bremner
b010584163 CLI/git: rename environment variables.
Although the code required to support both new and old environment
variables is small, it complicates the semantics of configuration, and
make the documentation harder to follow.
2022-06-17 08:40:19 -03:00
David Bremner
a85c82f99a test: initial tests for notmuch-git
Exercise the main functionality of notmuch-git.  add_git_repos() will
hopefully be simplifed when an init subcommand is added.
2022-06-17 08:40:19 -03:00
W. Trevor King
14ac68ae11 CLI/git: Add an 'init' command
For folks that want to start versioning a new tag-space, instead of
cloning one that someone else has already started.

The empty-blob hash-object call avoids errors like:

  $ nmbug commit
  error: invalid object 100644 e69de29bb2 for
'tags/...'
  fatal: git-write-tree: error building trees
  'git HASH(0x9ef3eb8) write-tree' exited with nonzero value

David Bremner suggested [1]:

  $ git hash-object -w /dev/null

instead of my Python version of:

  $ git hash-object -w --stdin <&-

but I expect that closing stdin is more portable than the /dev/null
path (which doesn't exist on Windows, for example).

The --bare init and use of NMBGIT as the work tree (what could go
wrong with an empty commit?) are suggestions from Michal Sojka [2].

[1]: id:87y4vu6uvf.fsf@maritornes.cs.unb.ca
     http://thread.gmane.org/gmane.mail.notmuch.general/18626/focus=18720
[2]: id:87a93a5or2.fsf@resox.2x.cz
     http://thread.gmane.org/gmane.mail.notmuch.general/19495/focus=19767
2022-06-17 08:40:19 -03:00
David Bremner
a01378e48d CLI/git: make existance of config branch optional on clone
This branch is actually only used by an associated
utility (notmuch-report), and notmuch-git works fine without it.
2022-06-17 08:40:19 -03:00
David Bremner
b7b111b9b5 notmuch-git: add --git-dir, --tag-prefix arguments
It is often more convenient to use command line arguments than
environment variables.
2022-06-17 08:40:19 -03:00
David Bremner
b7c31f6581 CLI/git: drop support for python < 3.2
Debian stable had python 3.4.2 3 releases ago (approximately 6 years
ago), so attempting to keep track of the changes in python is probably
no longer worthwhile. We already require python 3.5 for the
python-cffi bindings (although those are not yet used in notmuch-git).
2022-06-17 08:40:19 -03:00
David Bremner
803ac83c46 nmbug: promote to user tool "notmuch-git"
Initially just a rename, and drop the --version argument that clashes
with the global notmuch --version argument.
2022-06-17 08:40:19 -03:00
Renamed from devel/nmbug/nmbug (Browse further)