--- /dev/null
+Return-Path: <david@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 97F6C6DE021E\r
+ for <notmuch@notmuchmail.org>; Sun, 16 Aug 2015 05:58:54 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.125\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.125 tagged_above=-999 required=5 tests=[AWL=0.125]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id ZzCkr77msS7v for <notmuch@notmuchmail.org>;\r
+ Sun, 16 Aug 2015 05:58:52 -0700 (PDT)\r
+Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id A74F16DE009A\r
+ for <notmuch@notmuchmail.org>; Sun, 16 Aug 2015 05:58:52 -0700 (PDT)\r
+Received: from remotemail by gitolite.debian.net with local (Exim 4.80)\r
+ (envelope-from <david@tethera.net>)\r
+ id 1ZQxVk-0002n2-Bl; Sun, 16 Aug 2015 12:58:04 +0000\r
+Received: (nullmailer pid 17358 invoked by uid 1000); Sun, 16 Aug 2015\r
+ 12:57:54 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: David Mazieres <dm-list-email-notmuch@scs.stanford.edu>,\r
+ notmuch@notmuchmail.org\r
+Subject: Re: Enabling and disabling maildir.synchronize_flags\r
+In-Reply-To: <874mjzblwc.fsf@ta.scs.stanford.edu>\r
+References: <87r3orbqfn.fsf@ta.scs.stanford.edu>\r
+ <87r3n3fu7d.fsf@maritornes.cs.unb.ca> <874mjzblwc.fsf@ta.scs.stanford.edu>\r
+User-Agent: Notmuch/0.20.2 (http://notmuchmail.org) Emacs/24.5.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Sun, 16 Aug 2015 14:57:54 +0200\r
+Message-ID: <87614ffl0t.fsf@maritornes.cs.unb.ca>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\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: Sun, 16 Aug 2015 12:58:54 -0000\r
+\r
+David Mazieres <dm-list-email-notmuch@scs.stanford.edu> writes:\r
+\r
+\r
+> So my question remains, what's the easiest safe way to re-enable\r
+> synchronize_flags after disabling it? (Safe meaning it won't change any\r
+> tags.) It could be that there's a very simple answer, in which case\r
+> sticking it in the man page might be nice.\r
+\r
+I can't think of a simple, safe, and fast answer.\r
+\r
+As a hack, if you run notmuch new right before you enable\r
+synchronize_flags, then next the next notmuch new will not notice the\r
+fact that flags are out of sync [1]. I don't think this really qualifies\r
+as safe, as the fact that the maildir is out of sync with the database\r
+will eventually bite you. Maybe in some special circumstances this\r
+helps.\r
+\r
+Otherwise, two things to that might speed up the process.\r
+\r
+1) dump and restore both take queries, so you can only worry about the\r
+maildir relevant flags.\r
+\r
+2) when the lastmod changes go in, it seems like you could run the first\r
+ notmuch new after enabling tag synchonizing, and dump only the tag\r
+ changes since a checkpoint lastmod value. This would allow rolling\r
+ back the unwanted tag changes.\r
+\r
+\r
+[1]: see this potential test, if for some reason we wanted to\r
+ guarantee this behaviours.\r
+ \r
+test_begin_subtest "Turning on maildir.synchronize_flags w/o backup"\r
+OLDCONFIG=$(notmuch config get maildir.synchronize_flags)\r
+\r
+notmuch config set maildir.synchronize_flags true\r
+add_message [subject]='"Message to test ignoring flags"' \\r
+ [date]='"Sat, 01 Jan 2000 12:00:00 -0000"' \\r
+ [filename]='ignoring-flags' [dir]=cur\r
+${NOTMUCH_NEW}\r
+notmuch dump > EXPECTED\r
+\r
+notmuch config set maildir.synchronize_flags false\r
+# make flags out of sync with db\r
+mv ${MAIL_DIR}/cur/ignoring-flags ${MAIL_DIR}/cur/ignoring-flags,S\r
+${NOTMUCH_NEW}\r
+\r
+notmuch config set maildir.synchronize_flags true\r
+${NOTMUCH_NEW}\r
+notmuch dump > OUTPUT\r
+notmuch config set maildir.synchronize_flags "${OLDCONFIG}"\r
+test_expect_equal_file EXPECTED OUTPUT\r