1 Return-Path: <bremner@tethera.net>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id C3A75431FC2
\r
6 for <notmuch@notmuchmail.org>; Wed, 20 Feb 2013 14:24:54 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id koSFqtgl1+xC for <notmuch@notmuchmail.org>;
\r
16 Wed, 20 Feb 2013 14:24:54 -0800 (PST)
\r
17 Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238])
\r
18 (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 0963F431FB6
\r
21 for <notmuch@notmuchmail.org>; Wed, 20 Feb 2013 14:24:54 -0800 (PST)
\r
22 Received: from fctnnbsc30w-156034082078.dhcp-dynamic.fibreop.nb.bellaliant.net
\r
23 ([156.34.82.78] helo=zancas.localnet)
\r
24 by tesseract.cs.unb.ca with esmtpsa
\r
25 (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80)
\r
26 (envelope-from <bremner@tethera.net>)
\r
27 id 1U8I5q-00086R-OM; Wed, 20 Feb 2013 18:24:51 -0400
\r
28 Received: from bremner by zancas.localnet with local (Exim 4.80)
\r
29 (envelope-from <bremner@tethera.net>)
\r
30 id 1U8I5l-00028C-1I; Wed, 20 Feb 2013 18:24:45 -0400
\r
31 From: david@tethera.net
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: [Patch v2 1/4] nmbug: use dump --format=batch-tag
\r
34 Date: Wed, 20 Feb 2013 18:24:34 -0400
\r
35 Message-Id: <1361399077-7737-2-git-send-email-david@tethera.net>
\r
36 X-Mailer: git-send-email 1.7.10.4
\r
37 In-Reply-To: <1361399077-7737-1-git-send-email-david@tethera.net>
\r
38 References: <1361399077-7737-1-git-send-email-david@tethera.net>
\r
40 Cc: David Bremner <bremner@debian.org>
\r
41 X-BeenThere: notmuch@notmuchmail.org
\r
42 X-Mailman-Version: 2.1.13
\r
44 List-Id: "Use and development of the notmuch mail system."
\r
45 <notmuch.notmuchmail.org>
\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
49 List-Post: <mailto:notmuch@notmuchmail.org>
\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
52 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
53 X-List-Received-Date: Wed, 20 Feb 2013 22:24:55 -0000
\r
55 From: David Bremner <bremner@debian.org>
\r
57 This should make nmbug tolerate tags with whitespace and other special
\r
58 characters it. At the moment this relies on _not_ passing calls to
\r
59 notmuch tag through the shell, which is a documented feature of perl's
\r
62 devel/nmbug/nmbug | 27 ++++++++++++++++++++-------
\r
63 1 file changed, 20 insertions(+), 7 deletions(-)
\r
65 diff --git a/devel/nmbug/nmbug b/devel/nmbug/nmbug
\r
66 index fe103b3..befc3d9 100755
\r
67 --- a/devel/nmbug/nmbug
\r
68 +++ b/devel/nmbug/nmbug
\r
69 @@ -39,6 +39,11 @@ my %command = (
\r
70 status => \&do_status,
\r
73 +# Convert prefix into form suitable for literal matching against
\r
74 +# notmuch dump --format=batch-tag output.
\r
75 +my $ENCPREFIX = encode_for_fs ($TAGPREFIX);
\r
76 +$ENCPREFIX =~ s/:/%3a/g;
\r
78 my $subcommand = shift || usage ();
\r
80 if (!exists $command{$subcommand}) {
\r
81 @@ -203,9 +208,9 @@ sub index_tags {
\r
83 my $index = $NMBGIT.'/nmbug.index';
\r
85 - my $query = join ' ', map ("tag:$_", get_tags ($TAGPREFIX));
\r
86 + my $query = join ' ', map ("tag:\"$_\"", get_tags ($TAGPREFIX));
\r
88 - my $fh = spawn ('-|', qw/notmuch dump --/, $query)
\r
89 + my $fh = spawn ('-|', qw/notmuch dump --format=batch-tag --/, $query)
\r
90 or die "notmuch dump: $!";
\r
92 git ('read-tree', '--empty');
\r
93 @@ -214,22 +219,30 @@ sub index_tags {
\r
94 or die 'git update-index';
\r
97 - m/ ( [^ ]* ) \s+ \( ([^\)]* ) \) /x || die 'syntax error in dump';
\r
98 - my ($id,$rest) = ($1,$2);
\r
100 - #strip prefixes before writing
\r
101 - my @tags = grep { s/^$TAGPREFIX//; } split (' ', $rest);
\r
103 + my ($rest,$id) = split(/ -- id:/);
\r
105 + if ($id =~ s/^"(.*)"\s*$/$1/) {
\r
106 + # xapian quoted string, dequote.
\r
110 + #strip prefixes from tags before writing
\r
111 + my @tags = grep { s/^[+]$ENCPREFIX//; } split (' ', $rest);
\r
112 index_tags_for_msg ($git,$id, 'A', @tags);
\r
114 unless (close $git) {
\r
115 die "'git update-index --index-info' exited with nonzero value\n";
\r
117 unless (close $fh) {
\r
118 - die "'notmuch dump -- $query' exited with nonzero value\n";
\r
119 + die "'notmuch dump --format=batch-tag -- $query' exited with nonzero value\n";
\r
124 +# update the git index to either create or delete an empty file.
\r
125 +# Neither argument should be encoded/escaped.
\r
126 sub index_tags_for_msg {
\r