From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id +BDZIuyVm2LegAEAbAwnHQ (envelope-from ) for ; Sat, 04 Jun 2022 19:27:08 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id /HjmIeyVm2IvUQEAG6o9tA (envelope-from ) for ; Sat, 04 Jun 2022 19:27:08 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [IPv6:2a01:4f9:c011:7a79::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 106511CD73 for ; Sat, 4 Jun 2022 19:27:07 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id CF86E5F7CA; Sat, 4 Jun 2022 17:27:05 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id DB6335F7AE for ; Sat, 4 Jun 2022 17:23:27 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id CC41C5FBD7; Sat, 4 Jun 2022 13:23:26 -0400 (EDT) Received: (nullmailer pid 1150048 invoked by uid 1000); Sat, 04 Jun 2022 17:23:25 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: Date: Sat, 4 Jun 2022 14:22:56 -0300 Message-Id: <20220604172313.1149879-1-david@tethera.net> X-Mailer: git-send-email 2.35.2 MIME-Version: 1.0 X-MailFrom: bremner@tethera.net X-Mailman-Rule-Hits: no-subject X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; digests; suspicious-header Message-ID-Hash: QIEAQQX3FOKITB3GRWXLJN3HVAJ7Q4KC X-Message-ID-Hash: QIEAQQX3FOKITB3GRWXLJN3HVAJ7Q4KC X-Mailman-Approved-At: Sat, 04 Jun 2022 17:27:03 +0000 X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1654363628; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=jGjh9VX5U5ZGpGofL6qifFPew1Z5iSRh/VzDUu4YmUU=; b=py4UwBlD+5+pYgYcbJO/8K0FObHbYFQcFhqaopFTYpcEH6pkZygcxjQTJlZq3eK5ifh4rT FMYsfG1GwfqSD6G4XQZ+VDQS7k/wsgP3ji2+2J7ZkzvrWXR0CYBpSGYGF7BT48TAaOtaJ4 GxmzfyKbF5prcQnFNCVxM4gnCPPULf+bp6imeLuZAyjJARd/lXB7WtEMFdkFHKIhgaVhpj t2ku/SkpBRhuVfHcHsQprIdodjayIwd05ptn1sctxAorPTI0m4k2VJDeHgxfe+oLn/1Qor 7NH/bNkfHCSfi+QRn1qexAb02qN6A9J9bVkNZ1f0bm55rIpLRygu0sR9+9Wgsw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1654363628; a=rsa-sha256; cv=none; b=tAHZO7jgduvxNsRZQXz7e7A3J8Mf5eUAkfUsgXpfnHjwImG7BPzgyzv3Fx02hnqn29wN+k bynwvpa/E+ZYfP1ZLXF6lm55skjq/qVE8p7TCgeqqXNgmn/+3qkBOGSq3Dhu+NDObT/Azy dyWOCBkgFvN4De4B7IlaiUl/KDQD/1V7P/lMHSSUjbfmLeZVPZEYqYMXqCr/55Js2FthgL Xk8YaCzKT7GV9r2SftdAP7gCZJ3G1K7cqyhxu+HnDt2P2RHb5BRGYpjDD+/rHbkQHvnXco ghzAgo/jX9Q49ulBy9nBkJDuadrPyDcOjk6oLmcaRVpqCX52iHnP/tiVWYXIHw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -0.05 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 106511CD73 X-Spam-Score: -0.05 X-Migadu-Scanner: scn0.migadu.com X-TUID: AjIDsCWl/7Nl This series is against branch "next", which is currently ahead of master by the following 7 commits 9c1ed5ab CLI: document handling of --config for external commands 0d33392f CLI: pass --config to external commands via NOTMUCH_CONFIG. 163dae81 test: initial tests for external commands a5a3ed90 CLI: set NOTMUCH_CONFIG in hooks. cd050fd7 test: add known broken tests for setting NOTMUCH_CONFIG in hooks e7732d21 CLI: mention sexp-queries in help topics, alphabetize 383d9db2 CLI: simplify help command These are all on the list, and will probably be applied to master within the next week or so. The changes since last version are not too huge (interdiff at the end). Functional changes are as follows - drop --version command for notmuch commit (people can use notmuch --version to get the same info) - check that there are tags with the given prefix in the database already; if not require --force to proceed. - enable --config handling (this is actually in the prerequisite patches in branch next). diff --git a/Makefile.local b/Makefile.local index 0fadfb26..7699c208 100644 --- a/Makefile.local +++ b/Makefile.local @@ -45,6 +45,15 @@ $(SHA256_FILE): $(TAR_FILE) $(DETACHED_SIG_FILE): $(TAR_FILE) gpg --armor --detach-sign $^ +CLEAN := $(CLEAN) notmuch-git +notmuch-git: notmuch-git.py + cp $< $@ + chmod ugo+x $@ + +CLEAN := $(CLEAN) nmbug +nmbug: notmuch-git + ln -s $< $@ + .PHONY: dist dist: $(TAR_FILE) @@ -294,7 +303,7 @@ endif SRCS := $(SRCS) $(notmuch_client_srcs) CLEAN := $(CLEAN) notmuch notmuch-shared $(notmuch_client_modules) CLEAN := $(CLEAN) version.stamp notmuch-*.tar.gz.tmp -CLEAN := $(CLEAN) .deps notmuch-git +CLEAN := $(CLEAN) .deps DISTCLEAN := $(DISTCLEAN) .first-build-message Makefile.config sh.config sphinx.config @@ -307,10 +316,6 @@ cppcheck: @echo "No cppcheck found during configure; skipping static checking" endif -nmbug notmuch-git: notmuch-git.in - sed s/@NOTMUCH_VERSION@/${VERSION}/ < notmuch-git.in > notmuch-git - chmod ugo+rx notmuch-git - ln -sf notmuch-git nmbug DEPS := $(SRCS:%.c=.deps/%.d) DEPS := $(DEPS:%.cc=.deps/%.d) diff --git a/notmuch-git.in b/notmuch-git.py old mode 100755 new mode 100644 similarity index 99% rename from notmuch-git.in rename to notmuch-git.py index 6505c2e5..24ab3e5c --- a/notmuch-git.in +++ b/notmuch-git.py @@ -40,8 +40,6 @@ from urllib.parse import quote as _quote from urllib.parse import unquote as _unquote import json as _json -__version__ = '@NOTMUCH_VERSION@' - _LOG = _logging.getLogger('nmbug') _LOG.setLevel(_logging.WARNING) _LOG.addHandler(_logging.StreamHandler()) @@ -376,6 +374,10 @@ def check_safe_fraction(status): safe=float(conf) total = count_messages (TAG_PREFIX) + if total == 0: + _LOG.error('No existing tags with given prefix, stopping.'.format(safe)) + _LOG.error('Use --force to override.') + exit(1) change = len(status['added'])+len(status['deleted'])+len(status['missing']) fraction = change/total _LOG.debug('total messages {:d}, change: {:d}, fraction: {:f}'.format(total,change,fraction)) @@ -931,9 +933,6 @@ if __name__ == '__main__': parser.add_argument( '-N', '--nmbug', action='store_true', help='Set defaults for --tag-prefix and --git-dir for the notmuch bug tracker') - parser.add_argument( - '-v', '--version', action='version', - version='%(prog)s {}'.format(__version__)) parser.add_argument( '-l', '--log-level', choices=['critical', 'error', 'warning', 'info', 'debug'], diff --git a/notmuch.c b/notmuch.c index a6c49bcb..c75b0188 100644 --- a/notmuch.c +++ b/notmuch.c @@ -201,8 +201,6 @@ static const command_t commands[] = { { "emacs-mua", NULL, 0, "send mail with notmuch and emacs." }, #endif - { "git", NULL, 0, - "manage notmuch tags with git" }, { "help", notmuch_help_command, NOTMUCH_COMMAND_CONFIG_CREATE, /* create but don't save config */ "This message, or more detailed help for the named command." } }; diff --git a/test/T850-git.sh b/test/T850-git.sh index 508615e1..7ea50939 100755 --- a/test/T850-git.sh +++ b/test/T850-git.sh @@ -7,6 +7,9 @@ if [ $NOTMUCH_HAVE_SFSEXP -ne 1 ]; then test_done fi +# be very careful using backup_database / restore_database in this +# file, as they fool the cache invalidation checks in notmuch-git. + add_email_corpus git config --global user.email notmuch@example.org @@ -28,6 +31,35 @@ test_expect_success "notmuch git -p '' -C tags.git clone remote.git" test_begin_subtest "initial commit needs force" test_expect_code 1 "notmuch git -C tags.git commit" +test_begin_subtest "committing new prefix requires force" +notmuch git -C force-prefix.git init +notmuch tag +new-prefix::foo id:20091117190054.GU3165@dottiness.seas.harvard.edu +test_expect_code 1 "notmuch git -l debug -p 'new-prefix::' -C force-prefix.git commit" +notmuch tag -new-prefix::foo id:20091117190054.GU3165@dottiness.seas.harvard.edu + +test_begin_subtest "committing new prefix works with force" +notmuch tag +new-prefix::foo id:20091117190054.GU3165@dottiness.seas.harvard.edu +notmuch git -l debug -p 'new-prefix::' -C force-prefix.git commit --force +git -C force-prefix.git ls-tree -r --name-only HEAD | xargs dirname | sort -u | sed s,tags/,id:, > OUTPUT +notmuch tag -new-prefix::foo id:20091117190054.GU3165@dottiness.seas.harvard.edu +cat <EXPECTED +id:20091117190054.GU3165@dottiness.seas.harvard.edu +EOF +test_expect_equal_file_nonempty EXPECTED OUTPUT + +test_begin_subtest "checkout new prefix requires force" +test_expect_code 1 "notmuch git -l debug -p 'new-prefix::' -C force-prefix.git checkout" + +test_begin_subtest "checkout new prefix works with force" +notmuch dump > BEFORE +notmuch git -l debug -p 'new-prefix::' -C force-prefix.git checkout --force +notmuch dump --include=tags id:20091117190054.GU3165@dottiness.seas.harvard.edu | grep -v '^#' > OUTPUT +notmuch restore < BEFORE +cat < EXPECTED ++inbox +new-prefix%3a%3afoo +signed +unread -- id:20091117190054.GU3165@dottiness.seas.harvard.edu +EOF +test_expect_equal_file_nonempty EXPECTED OUTPUT + test_begin_subtest "commit" notmuch git -C tags.git commit --force git -C tags.git ls-tree -r --name-only HEAD | xargs dirname | sort -u | sed s,tags/,id:, > OUTPUT @@ -138,6 +170,17 @@ EOF notmuch git -C tags.git checkout test_expect_equal_file EXPECTED OUTPUT +test_begin_subtest "status (global config argument)" +cp notmuch-config notmuch-config.new +notmuch --config=notmuch-config.new config set git.path tags.git +notmuch tag +test id:20091117190054.GU3165@dottiness.seas.harvard.edu +notmuch --config=./notmuch-config.new git status > OUTPUT +cat < EXPECTED +A 20091117190054.GU3165@dottiness.seas.harvard.edu test +EOF +notmuch --config=notmuch-config.new git checkout +test_expect_equal_file EXPECTED OUTPUT + test_begin_subtest "fetch" notmuch tag +test2 id:20091117190054.GU3165@dottiness.seas.harvard.edu notmuch git -C remote.git commit --force