[PATCH 11/18] insert: apply command-line tag operations
authorPeter Wang <novalazy@gmail.com>
Wed, 25 Jul 2012 13:42:40 +0000 (23:42 +1000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:48:36 +0000 (09:48 -0800)
be/04fea205c7231717429e1998a4cf98572f531f [new file with mode: 0644]

diff --git a/be/04fea205c7231717429e1998a4cf98572f531f b/be/04fea205c7231717429e1998a4cf98572f531f
new file mode 100644 (file)
index 0000000..5739d2a
--- /dev/null
@@ -0,0 +1,128 @@
+Return-Path: <novalazy@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id B87DA431FD5\r
+       for <notmuch@notmuchmail.org>; Wed, 25 Jul 2012 06:44:39 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id bMwLy+6nkyOi for <notmuch@notmuchmail.org>;\r
+       Wed, 25 Jul 2012 06:44:38 -0700 (PDT)\r
+Received: from mail-gg0-f181.google.com (mail-gg0-f181.google.com\r
+       [209.85.161.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 45951431FD9\r
+       for <notmuch@notmuchmail.org>; Wed, 25 Jul 2012 06:44:16 -0700 (PDT)\r
+Received: by ggnv5 with SMTP id v5so883639ggn.26\r
+       for <notmuch@notmuchmail.org>; Wed, 25 Jul 2012 06:44:15 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       bh=j0lUFfrSEJ14+yeNmyCQqFdbH/kU+cbewfgsOnHhcZs=;\r
+       b=YHDPlfqWDAxHwoTfs+pniq6ljfrXYtlKsphCMyEE7K7wBCRSEMMndzrwaw2gzcPk6o\r
+       BcRB2lv3FS54VYsPabzn9QTuMfNl7d2NfqovbnrzBOLYSFppI3CUQretJ9aQEOuPvjOu\r
+       xrfhUMswYG85QHFXJOENmrkdR15vRn72lSDn3L8Wdn3PGlmvxLSVT5o4JVYORFYYhE+M\r
+       wBCJre1ocgceyQVPwQhHzRk7AambAudcCjoAqKKqT8QVWpI84wgZzrDmoerz0xvHZfz2\r
+       qMoxf0l+luYPOqX1aBVKYkzRoC0yyX2TQLAWs5SBdPczUke+J0VwyjG2ATLJDCbmyzSc\r
+       CbBg==\r
+Received: by 10.66.73.5 with SMTP id h5mr12788745pav.79.1343223855447;\r
+       Wed, 25 Jul 2012 06:44:15 -0700 (PDT)\r
+Received: from localhost (215.42.233.220.static.exetel.com.au.\r
+       [220.233.42.215])\r
+       by mx.google.com with ESMTPS id wi6sm14414420pbc.35.2012.07.25.06.44.12\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Wed, 25 Jul 2012 06:44:14 -0700 (PDT)\r
+From: Peter Wang <novalazy@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 11/18] insert: apply command-line tag operations\r
+Date: Wed, 25 Jul 2012 23:42:40 +1000\r
+Message-Id: <1343223767-9812-11-git-send-email-novalazy@gmail.com>\r
+X-Mailer: git-send-email 1.7.4.4\r
+In-Reply-To: <1343223767-9812-1-git-send-email-novalazy@gmail.com>\r
+References: <1343223767-9812-1-git-send-email-novalazy@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 25 Jul 2012 13:44:40 -0000\r
+\r
+Apply the +tag and -tag operations which were specified on the\r
+command-line.\r
+---\r
+ notmuch-insert.c |   18 ++++++++++++++----\r
+ 1 files changed, 14 insertions(+), 4 deletions(-)\r
+\r
+diff --git a/notmuch-insert.c b/notmuch-insert.c\r
+index 6db03e3..5fd79be 100644\r
+--- a/notmuch-insert.c\r
++++ b/notmuch-insert.c\r
+@@ -151,7 +151,7 @@ copy_fd_data (int fdin, int fdout)\r
+ \r
+ static notmuch_bool_t\r
+ save_database (notmuch_database_t *notmuch, const char *path,\r
+-             const char **new_tags)\r
++             const char **new_tags, const tag_operation_t *tag_ops)\r
+ {\r
+     notmuch_message_t *message;\r
+     notmuch_status_t status;\r
+@@ -186,6 +186,14 @@ save_database (notmuch_database_t *notmuch, const char *path,\r
+       notmuch_message_add_tag (message, new_tags[i]);\r
+     }\r
+ \r
++    for (i = 0; tag_ops[i].tag; i++) {\r
++      if (tag_ops[i].remove) {\r
++          notmuch_message_remove_tag (message, tag_ops[i].tag);\r
++      } else {\r
++          notmuch_message_add_tag (message, tag_ops[i].tag);\r
++      }\r
++    }\r
++\r
+     notmuch_message_thaw (message);\r
+ \r
+     notmuch_message_tags_to_maildir_flags (message);\r
+@@ -197,7 +205,8 @@ save_database (notmuch_database_t *notmuch, const char *path,\r
+ \r
+ static notmuch_bool_t\r
+ insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,\r
+-              const char *dir, const char **new_tags)\r
++              const char *dir, const char **new_tags,\r
++              const tag_operation_t *tag_ops)\r
+ {\r
+     char *tmppath;\r
+     char *newpath;\r
+@@ -222,7 +231,7 @@ insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,\r
+       return FALSE;\r
+     }\r
+ \r
+-    ret = save_database (notmuch, newpath, new_tags);\r
++    ret = save_database (notmuch, newpath, new_tags, tag_ops);\r
+ \r
+     if (!ret) {\r
+       /* XXX maybe there should be an option to keep the file in maildir? */\r
+@@ -324,7 +333,8 @@ notmuch_insert_command (void *ctx, int argc, char *argv[])\r
+                              NOTMUCH_DATABASE_MODE_READ_WRITE, &notmuch))\r
+       return 1;\r
+ \r
+-    ret = insert_message (ctx, notmuch, STDIN_FILENO, maildir, new_tags);\r
++    ret = insert_message (ctx, notmuch, STDIN_FILENO, maildir, new_tags,\r
++                        tag_ops);\r
+ \r
+     notmuch_database_destroy (notmuch);\r
+ \r
+-- \r
+1.7.4.4\r
+\r