unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] notmuch-tag: Allow using both --remove-all and --batch
@ 2015-08-11  7:46 Daniel Schoepe
  2015-08-11  7:46 ` [PATCH 1/2] cli: Allow combining " Daniel Schoepe
  2015-08-11  7:46 ` [PATCH 2/2] test: Tests for combining --batch and --remove-all Daniel Schoepe
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Schoepe @ 2015-08-11  7:46 UTC (permalink / raw)
  To: notmuch

Hi,

I noticed that it makes sense to combine the --batch and --remove-all
options to notmuch. This can be used, for instance, when synchronizing
tags by transferring the tags for all changed mails.

This series removes this (undocumented) restriction and adds some
tests.

Best regards,
Daniel

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

* [PATCH 1/2] cli: Allow combining --remove-all and --batch
  2015-08-11  7:46 [PATCH] notmuch-tag: Allow using both --remove-all and --batch Daniel Schoepe
@ 2015-08-11  7:46 ` Daniel Schoepe
  2015-11-19 11:58   ` David Bremner
  2015-08-11  7:46 ` [PATCH 2/2] test: Tests for combining --batch and --remove-all Daniel Schoepe
  1 sibling, 1 reply; 4+ messages in thread
From: Daniel Schoepe @ 2015-08-11  7:46 UTC (permalink / raw)
  To: notmuch

This patch removes the restriction on notmuch-tag that disallows using
both --remove-all and --batch. Combining the two options removes tags
on all messages affected by each query before applying the new tags.
---
 notmuch-tag.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/notmuch-tag.c b/notmuch-tag.c
index 38d99aa..f1df986 100644
--- a/notmuch-tag.c
+++ b/notmuch-tag.c
@@ -231,10 +231,6 @@ notmuch_tag_command (notmuch_config_t *config, int argc, char *argv[])
 	    fprintf (stderr, "Can't specify both cmdline and stdin!\n");
 	    return EXIT_FAILURE;
 	}
-	if (remove_all) {
-	    fprintf (stderr, "Can't specify both --remove-all and --batch\n");
-	    return EXIT_FAILURE;
-	}
     } else {
 	tag_ops = tag_op_list_create (config);
 	if (tag_ops == NULL) {
-- 
2.5.0

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

* [PATCH 2/2] test: Tests for combining --batch and --remove-all
  2015-08-11  7:46 [PATCH] notmuch-tag: Allow using both --remove-all and --batch Daniel Schoepe
  2015-08-11  7:46 ` [PATCH 1/2] cli: Allow combining " Daniel Schoepe
@ 2015-08-11  7:46 ` Daniel Schoepe
  1 sibling, 0 replies; 4+ messages in thread
From: Daniel Schoepe @ 2015-08-11  7:46 UTC (permalink / raw)
  To: notmuch

This patch adds some tests for combining --remove-all with --batch or
--input when calling notmuch-tag.
---
 test/T150-tagging.sh | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/test/T150-tagging.sh b/test/T150-tagging.sh
index 821d393..19539dd 100755
--- a/test/T150-tagging.sh
+++ b/test/T150-tagging.sh
@@ -38,6 +38,16 @@ test_expect_equal "$output" "\
 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One ()
 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (tag5 tag6 unread)"
 
+test_begin_subtest "Remove all with batch"
+notmuch tag --remove-all --batch <<EOF
++tag1 -- One
++tag3 +tag4 +inbox -- Two
+EOF
+output=$(notmuch search \* | notmuch_search_sanitize)
+test_expect_equal "$output" "\
+thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (tag1)
+thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag3 tag4)"
+
 test_begin_subtest "Remove all with a no-op"
 notmuch tag +inbox +tag1 +unread One
 notmuch tag --remove-all +foo +inbox +tag1 -foo +unread Two
@@ -102,6 +112,20 @@ notmuch search \* | notmuch_search_sanitize > OUTPUT
 notmuch restore --format=batch-tag < backup.tags
 test_expect_equal_file batch.expected OUTPUT
 
+test_begin_subtest "--batch --input --remove-all"
+notmuch dump --format=batch-tag > backup.tags
+notmuch tag +foo +bar -- One
+notmuch tag +tag7 -- Two
+notmuch tag --batch --input=batch.in --remove-all
+notmuch search \* | notmuch_search_sanitize > OUTPUT
+notmuch restore --format=batch-tag < backup.tags
+cat > batch_removeall.expected <<EOF
+thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (@ tag6)
+thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (tag6)
+EOF
+test_expect_equal_file batch_removeall.expected OUTPUT
+rm batch_removeall.expected
+
 test_begin_subtest "--batch, blank lines and comments"
 notmuch dump | sort > EXPECTED
 notmuch tag --batch <<EOF
-- 
2.5.0

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

* Re: [PATCH 1/2] cli: Allow combining --remove-all and --batch
  2015-08-11  7:46 ` [PATCH 1/2] cli: Allow combining " Daniel Schoepe
@ 2015-11-19 11:58   ` David Bremner
  0 siblings, 0 replies; 4+ messages in thread
From: David Bremner @ 2015-11-19 11:58 UTC (permalink / raw)
  To: Daniel Schoepe, notmuch

Daniel Schoepe <daniel@schoepe.org> writes:

> This patch removes the restriction on notmuch-tag that disallows using
> both --remove-all and --batch. Combining the two options removes tags
> on all messages affected by each query before applying the new tags.

pushed,

d

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

end of thread, other threads:[~2015-11-19 11:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-11  7:46 [PATCH] notmuch-tag: Allow using both --remove-all and --batch Daniel Schoepe
2015-08-11  7:46 ` [PATCH 1/2] cli: Allow combining " Daniel Schoepe
2015-11-19 11:58   ` David Bremner
2015-08-11  7:46 ` [PATCH 2/2] test: Tests for combining --batch and --remove-all Daniel Schoepe

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).