--- /dev/null
+Return-Path: <tomi.ollila@iki.fi>\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 1127C431FC0\r
+ for <notmuch@notmuchmail.org>; Wed, 1 Jan 2014 08:30:51 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ 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 0RBL7aHw0V9W for <notmuch@notmuchmail.org>;\r
+ Wed, 1 Jan 2014 08:30:43 -0800 (PST)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id 5DFA7431FAF\r
+ for <notmuch@notmuchmail.org>; Wed, 1 Jan 2014 08:30:43 -0800 (PST)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id A63801000B2;\r
+ Wed, 1 Jan 2014 18:30:35 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 2/2] insert: respect maildir.synchronize_flags\r
+In-Reply-To: <1388589614-19671-2-git-send-email-jani@nikula.org>\r
+References: <1388589614-19671-1-git-send-email-jani@nikula.org>\r
+ <1388589614-19671-2-git-send-email-jani@nikula.org>\r
+User-Agent: Notmuch/0.17+13~gdfcf116 (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+ $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+ !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Wed, 01 Jan 2014 18:30:35 +0200\r
+Message-ID: <m2k3ejfyvo.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\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, 01 Jan 2014 16:30:51 -0000\r
+\r
+On Wed, Jan 01 2014, Jani Nikula <jani@nikula.org> wrote:\r
+\r
+> Don't synchronize maildir flags if the user doesn't want it.\r
+> ---\r
+\r
+Looks good, tests pass.\r
+\r
+Tomi\r
+\r
+\r
+> notmuch-insert.c | 24 ++++++++++++++++--------\r
+> test/insert | 1 -\r
+> 2 files changed, 16 insertions(+), 9 deletions(-)\r
+>\r
+> diff --git a/notmuch-insert.c b/notmuch-insert.c\r
+> index 2207b1e..55384e3 100644\r
+> --- a/notmuch-insert.c\r
+> +++ b/notmuch-insert.c\r
+> @@ -295,7 +295,7 @@ copy_stdin (int fdin, int fdout)\r
+> * The file is renamed to encode notmuch tags as maildir flags. */\r
+> static void\r
+> add_file_to_database (notmuch_database_t *notmuch, const char *path,\r
+> - tag_op_list_t *tag_ops)\r
+> + tag_op_list_t *tag_ops, notmuch_bool_t synchronize_flags)\r
+> {\r
+> notmuch_message_t *message;\r
+> notmuch_status_t status;\r
+> @@ -323,11 +323,15 @@ add_file_to_database (notmuch_database_t *notmuch, const char *path,\r
+> \r
+> if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) {\r
+> /* Don't change tags of an existing message. */\r
+> - status = notmuch_message_tags_to_maildir_flags (message);\r
+> - if (status != NOTMUCH_STATUS_SUCCESS)\r
+> - fprintf (stderr, "Error: failed to sync tags to maildir flags\n");\r
+> + if (synchronize_flags) {\r
+> + status = notmuch_message_tags_to_maildir_flags (message);\r
+> + if (status != NOTMUCH_STATUS_SUCCESS)\r
+> + fprintf (stderr, "Error: failed to sync tags to maildir flags\n");\r
+> + }\r
+> } else {\r
+> - tag_op_list_apply (message, tag_ops, TAG_FLAG_MAILDIR_SYNC);\r
+> + tag_op_flag_t flags = synchronize_flags ? TAG_FLAG_MAILDIR_SYNC : 0;\r
+> +\r
+> + tag_op_list_apply (message, tag_ops, flags);\r
+> }\r
+> \r
+> notmuch_message_destroy (message);\r
+> @@ -335,7 +339,8 @@ add_file_to_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, tag_op_list_t *tag_ops)\r
+> + const char *dir, tag_op_list_t *tag_ops,\r
+> + notmuch_bool_t synchronize_flags)\r
+> {\r
+> char *tmppath;\r
+> char *newpath;\r
+> @@ -377,7 +382,7 @@ insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,\r
+> \r
+> /* Even if adding the message to the notmuch database fails,\r
+> * the message is on disk and we consider the delivery completed. */\r
+> - add_file_to_database (notmuch, newpath, tag_ops);\r
+> + add_file_to_database (notmuch, newpath, tag_ops, synchronize_flags);\r
+> \r
+> return TRUE;\r
+> \r
+> @@ -400,6 +405,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])\r
+> char *query_string = NULL;\r
+> const char *folder = NULL;\r
+> notmuch_bool_t create_folder = FALSE;\r
+> + notmuch_bool_t synchronize_flags;\r
+> const char *maildir;\r
+> int opt_index;\r
+> unsigned int i;\r
+> @@ -420,6 +426,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])\r
+> \r
+> db_path = notmuch_config_get_database_path (config);\r
+> new_tags = notmuch_config_get_new_tags (config, &new_tags_length);\r
+> + synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);\r
+> \r
+> tag_ops = tag_op_list_create (config);\r
+> if (tag_ops == NULL) {\r
+> @@ -471,7 +478,8 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])\r
+> NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much))\r
+> return 1;\r
+> \r
+> - ret = insert_message (config, notmuch, STDIN_FILENO, maildir, tag_ops);\r
+> + ret = insert_message (config, notmuch, STDIN_FILENO, maildir, tag_ops,\r
+> + synchronize_flags);\r
+> \r
+> notmuch_database_destroy (notmuch);\r
+> \r
+> diff --git a/test/insert b/test/insert\r
+> index 9283e70..e8dc4c0 100755\r
+> --- a/test/insert\r
+> +++ b/test/insert\r
+> @@ -114,7 +114,6 @@ dirname=$(dirname "$output")\r
+> test_expect_equal "$dirname" "$MAIL_DIR/cur"\r
+> \r
+> test_begin_subtest "Insert message with maildir sync off goes to new/"\r
+> -test_subtest_known_broken\r
+> OLDCONFIG=$(notmuch config get maildir.synchronize_flags)\r
+> notmuch config set maildir.synchronize_flags false\r
+> gen_insert_msg\r
+> -- \r
+> 1.8.5.2\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r