From ded713c39d8b0221a3b1b2b52a74966c20c3aba8 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Sun, 9 Mar 2014 14:25:37 +0200 Subject: test: rearrange the test corpus into subfolders, fix tests We will need this for improved folder search tests, but having some folders should exercise our code paths better anyway. Modify the relevant test accordingly to make it pass. This reorganization triggers a bug in the test suite, namely that it expects the output of --output=files to be in a certain order. So we add the fix for that into the same commit. This mainly involves sorting, although the case --duplicate=$n requires more subtlety. --- test/corpus/bar/baz/05:2, | 104 +++++++++++++++++++++ test/corpus/bar/baz/23:2, | 145 ++++++++++++++++++++++++++++++ test/corpus/bar/baz/24:2, | 204 ++++++++++++++++++++++++++++++++++++++++++ test/corpus/bar/baz/cur/25:2, | 32 +++++++ test/corpus/bar/baz/cur/26:2, | 121 +++++++++++++++++++++++++ test/corpus/bar/baz/new/27:2, | 21 +++++ test/corpus/bar/baz/new/28:2, | 38 ++++++++ 7 files changed, 665 insertions(+) create mode 100644 test/corpus/bar/baz/05:2, create mode 100644 test/corpus/bar/baz/23:2, create mode 100644 test/corpus/bar/baz/24:2, create mode 100644 test/corpus/bar/baz/cur/25:2, create mode 100644 test/corpus/bar/baz/cur/26:2, create mode 100644 test/corpus/bar/baz/new/27:2, create mode 100644 test/corpus/bar/baz/new/28:2, (limited to 'test/corpus/bar/baz') diff --git a/test/corpus/bar/baz/05:2, b/test/corpus/bar/baz/05:2, new file mode 100644 index 00000000..75b05fa4 --- /dev/null +++ b/test/corpus/bar/baz/05:2, @@ -0,0 +1,104 @@ +MIME-Version: 1.0 +Date: Tue, 17 Nov 2009 11:36:14 -0800 +Message-ID: +From: Alex Botero-Lowry +To: notmuch@notmuchmail.org +Content-Type: multipart/mixed; boundary=0016e687869333b1570478963d35 +Subject: [notmuch] preliminary FreeBSD support +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.12 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +Sender: notmuch-bounces@notmuchmail.org +Errors-To: notmuch-bounces@notmuchmail.org + +--0016e687869333b1570478963d35 +Content-Type: multipart/alternative; boundary=0016e687869333b14e0478963d33 + +--0016e687869333b14e0478963d33 +Content-Type: text/plain; charset=ISO-8859-1 + +I saw the announcement this morning, and was very excited, as I had been +hoping sup would be turned into a library, +since I like the concept more than the UI (I'd rather an emacs interface). + +I did a preliminary compile which worked out fine, but +sysconf(_SC_SC_GETPW_R_SIZE_MAX) returns -1 on +FreeBSD, so notmuch_config_open segfaulted. + +Attached is a patch that supplies a default buffer size of 64 in cases where +-1 is returned. + +http://www.opengroup.org/austin/docs/austin_328.txt - seems to indicate this +is acceptable behavior, +and http://mail-index.netbsd.org/pkgsrc-bugs/2006/06/07/msg016808.htmlspecifically +uses 64 as the +buffer size. + +--0016e687869333b14e0478963d33 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable + +I saw the announcement this morning, and was very excited, as I had been ho= +ping sup would be turned into a library,
since I like the concept more t= +han the UI (I'd rather an emacs interface).

I did a preliminary = +compile which worked out fine, but sysconf(_SC_SC_GETPW_R_SIZE_MAX) returns= + -1 on
+FreeBSD, so notmuch_config_open segfaulted.

Attached is a patch that= + supplies a default buffer size of 64 in cases where -1 is returned.
http://www= +.opengroup.org/austin/docs/austin_328.txt - seems to indicate this is a= +cceptable behavior,
+and http://mail-index.netbsd.org/pkgsrc-bugs/2006/06/07/msg016808.html<= +/a> specifically uses 64 as the
buffer size.


+ +--0016e687869333b14e0478963d33-- +--0016e687869333b1570478963d35 +Content-Type: application/octet-stream; + name="0001-Deal-with-situation-where-sysconf-_SC_GETPW_R_SIZE_M.patch" +Content-Disposition: attachment; + filename="0001-Deal-with-situation-where-sysconf-_SC_GETPW_R_SIZE_M.patch" +Content-Transfer-Encoding: base64 +X-Attachment-Id: f_g252e6gs0 + +RnJvbSBlM2JjNGJiZDdiOWQwZDA4NjgxNmFiNWY4ZjJkNmZmZWExZGQzZWE0IE1vbiBTZXAgMTcg +MDA6MDA6MDAgMjAwMQpGcm9tOiBBbGV4YW5kZXIgQm90ZXJvLUxvd3J5IDxhbGV4LmJvdGVyb2xv +d3J5QGdtYWlsLmNvbT4KRGF0ZTogVHVlLCAxNyBOb3YgMjAwOSAxMTozMDozOSAtMDgwMApTdWJq +ZWN0OiBbUEFUQ0hdIERlYWwgd2l0aCBzaXR1YXRpb24gd2hlcmUgc3lzY29uZihfU0NfR0VUUFdf +Ul9TSVpFX01BWCkgcmV0dXJucyAtMQoKLS0tCiBub3RtdWNoLWNvbmZpZy5jIHwgICAgMiArKwog +MSBmaWxlcyBjaGFuZ2VkLCAyIGluc2VydGlvbnMoKyksIDAgZGVsZXRpb25zKC0pCgpkaWZmIC0t +Z2l0IGEvbm90bXVjaC1jb25maWcuYyBiL25vdG11Y2gtY29uZmlnLmMKaW5kZXggMjQ4MTQ5Yy4u +ZTcyMjBkOCAxMDA2NDQKLS0tIGEvbm90bXVjaC1jb25maWcuYworKysgYi9ub3RtdWNoLWNvbmZp +Zy5jCkBAIC03Nyw2ICs3Nyw3IEBAIHN0YXRpYyBjaGFyICoKIGdldF9uYW1lX2Zyb21fcGFzc3dk +X2ZpbGUgKHZvaWQgKmN0eCkKIHsKICAgICBsb25nIHB3X2J1Zl9zaXplID0gc3lzY29uZihfU0Nf +R0VUUFdfUl9TSVpFX01BWCk7CisgICAgaWYgKHB3X2J1Zl9zaXplID09IC0xKSBwd19idWZfc2l6 +ZSA9IDY0OwogICAgIGNoYXIgKnB3X2J1ZiA9IHRhbGxvY196ZXJvX3NpemUgKGN0eCwgcHdfYnVm +X3NpemUpOwogICAgIHN0cnVjdCBwYXNzd2QgcGFzc3dkLCAqaWdub3JlZDsKICAgICBjaGFyICpu +YW1lOwpAQCAtMTAxLDYgKzEwMiw3IEBAIHN0YXRpYyBjaGFyICoKIGdldF91c2VybmFtZV9mcm9t +X3Bhc3N3ZF9maWxlICh2b2lkICpjdHgpCiB7CiAgICAgbG9uZyBwd19idWZfc2l6ZSA9IHN5c2Nv +bmYoX1NDX0dFVFBXX1JfU0laRV9NQVgpOworICAgIGlmIChwd19idWZfc2l6ZSA9PSAtMSkgcHdf +YnVmX3NpemUgPSA2NDsKICAgICBjaGFyICpwd19idWYgPSB0YWxsb2NfemVyb19zaXplIChjdHgs +IHB3X2J1Zl9zaXplKTsKICAgICBzdHJ1Y3QgcGFzc3dkIHBhc3N3ZCwgKmlnbm9yZWQ7CiAgICAg +Y2hhciAqbmFtZTsKLS0gCjEuNi41LjIKCg== +--0016e687869333b1570478963d35 +Content-Type: text/plain; charset="us-ascii" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Disposition: inline + +_______________________________________________ +notmuch mailing list +notmuch@notmuchmail.org +http://notmuchmail.org/mailman/listinfo/notmuch + +--0016e687869333b1570478963d35-- + diff --git a/test/corpus/bar/baz/23:2, b/test/corpus/bar/baz/23:2, new file mode 100644 index 00000000..9bb62d73 --- /dev/null +++ b/test/corpus/bar/baz/23:2, @@ -0,0 +1,145 @@ +Date: Tue, 17 Nov 2009 19:58:29 -0500 +From: Lars Kellogg-Stedman +To: notmuch +Message-ID: <20091118005829.GB25380@dottiness.seas.harvard.edu> +MIME-Version: 1.0 +User-Agent: Mutt/1.5.19 (2009-01-05) +Subject: [notmuch] "notmuch help" outputs to stderr? +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.12 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +Content-Type: multipart/mixed; boundary="===============1359248349==" +Sender: notmuch-bounces@notmuchmail.org +Errors-To: notmuch-bounces@notmuchmail.org + + +--===============1359248349== +Content-Type: multipart/signed; micalg=pgp-sha256; + protocol="application/pgp-signature"; boundary="L6iaP+gRLNZHKoI4" +Content-Disposition: inline + + +--L6iaP+gRLNZHKoI4 +Content-Type: multipart/mixed; boundary="z6Eq5LdranGa6ru8" +Content-Disposition: inline + + +--z6Eq5LdranGa6ru8 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +I'm just noticing that 'notmuch help ...' outputs to stderr, which +isn't terribly intuitive. For example, the obvious invocation: + + notmuch help | less + +=2E..isn't terribly helpful. + +I've attached a patch that lets usage() take a FILE * argument so that +you can output to stderr in response to usage errors, and stdout in +response to an explicit request. + +--=20 +Lars Kellogg-Stedman +Senior Technologist, Computing and Information Technology +Harvard University School of Engineering and Applied Sciences + + +--z6Eq5LdranGa6ru8 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: attachment; filename="notmuch-help.patch" +Content-Transfer-Encoding: quoted-printable + +diff --git a/notmuch.c b/notmuch.c +index c47e640..a35cb99 100644 +--- a/notmuch.c ++++ b/notmuch.c +@@ -157,23 +157,23 @@ command_t commands[] =3D { + }; +=20 + static void +-usage (void) ++usage (FILE *out) + { + command_t *command; + unsigned int i; +=20 +- fprintf (stderr, "Usage: notmuch [args...]\n"); +- fprintf (stderr, "\n"); +- fprintf (stderr, "Where and [args...] are as follows:\n"); +- fprintf (stderr, "\n"); ++ fprintf (out, "Usage: notmuch [args...]\n"); ++ fprintf (out, "\n"); ++ fprintf (out, "Where and [args...] are as follows:\n"); ++ fprintf (out, "\n"); +=20 + for (i =3D 0; i < ARRAY_SIZE (commands); i++) { + command =3D &commands[i]; +=20 +- fprintf (stderr, "\t%s\t%s\n\n", command->name, command->summary); ++ fprintf (out, "\t%s\t%s\n\n", command->name, command->summary); + } +=20 +- fprintf (stderr, "Use \"notmuch help \" for more details on e= +ach command.\n\n"); ++ fprintf (out, "Use \"notmuch help \" for more details on each= + command.\n\n"); + } +=20 + static int +@@ -183,8 +183,8 @@ notmuch_help_command (unused (void *ctx), int argc, cha= +r *argv[]) + unsigned int i; +=20 + if (argc =3D=3D 0) { +- fprintf (stderr, "The notmuch mail system.\n\n"); +- usage (); ++ fprintf (stdout, "The notmuch mail system.\n\n"); ++ usage (stdout); + return 0; + } +=20 + +--z6Eq5LdranGa6ru8-- + +--L6iaP+gRLNZHKoI4 +Content-Type: application/pgp-signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.9 (GNU/Linux) + +iQEcBAEBCAAGBQJLA0a1AAoJENdGlQYxQazYr78IAJtqTWIpBqSdOWqTzt/r4XNn +KJ5mWAoNfq4H+3kx3xoWOFYS7qAYeJoHQWCDbMdb+zEXvPX6hMFn9+OxRN+N5FdQ +uxGTugSG9xSsK28oGDCQUtr5uheo+tH0jygPjI+LTD97vjUYS4K2qzhLGFJmpLcj +1akMJXM0gSdPZT8dJyjxvC15pgboLspE4+b6jexXmd4UoFvXgqvjkYHeV4Wk+s0L +xu+HkCGXL9WHYc3t171fFAru4Zd1AUxFQl4BZ2Y+OqRZUrD28Mtz3zGQxbJQoifl +JFrgPAWioLN71SkVq/y+efjvGSl0osPpKU5dftMmyY1zV7k7mMlO08ZSJU+wANA= +=Iijt +-----END PGP SIGNATURE----- + +--L6iaP+gRLNZHKoI4-- + +--===============1359248349== +Content-Type: text/plain; charset="us-ascii" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Disposition: inline + +_______________________________________________ +notmuch mailing list +notmuch@notmuchmail.org +http://notmuchmail.org/mailman/listinfo/notmuch + +--===============1359248349==-- + diff --git a/test/corpus/bar/baz/24:2, b/test/corpus/bar/baz/24:2, new file mode 100644 index 00000000..c8000207 --- /dev/null +++ b/test/corpus/bar/baz/24:2, @@ -0,0 +1,204 @@ +Return-path: +Envelope-to: cworth@localhost +Delivery-date: Wed, 18 Nov 2009 01:43:47 -0800 +Received: from yoom.home.cworth.org ([127.0.0.1]) + by yoom.home.cworth.org with esmtp (Exim 4.69) + (envelope-from ) + id 1NAgpH-0005Ab-20 + for cworth@localhost; Wed, 18 Nov 2009 01:27:47 -0800 +X-Original-To: cworth@cworth.org +Delivered-To: cworth@cworth.org +Received: from olra.theworths.org [82.165.184.25] + by yoom.home.cworth.org with IMAP (fetchmail-6.3.9-rc2) + for (single-drop); Wed, 18 Nov 2009 01:27:47 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 12248431FC3 + for ; Tue, 17 Nov 2009 17:01:22 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -6.17 +X-Spam-Level: +X-Spam-Status: No, score=-6.17 tagged_above=-999 required=2 tests=[AWL=0.429, + BAYES_00=-2.599, RCVD_IN_DNSWL_MED=-4] autolearn=unavailable +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id TmBdVd1i-Wjb; Tue, 17 Nov 2009 17:01:20 -0800 (PST) +Received: from olra.theworths.org (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id AF876431FBC; + Tue, 17 Nov 2009 17:01:20 -0800 (PST) +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 75784431FBC + for ; Tue, 17 Nov 2009 17:01:19 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id IoYHzHoKBskU for ; + Tue, 17 Nov 2009 17:01:18 -0800 (PST) +Received: from smtp-outbound.seas.harvard.edu (smtp-outbound.seas.harvard.edu + [140.247.51.171]) + by olra.theworths.org (Postfix) with ESMTP id 7E033431FAE + for ; Tue, 17 Nov 2009 17:01:18 -0800 (PST) +Received: from dottiness.seas.harvard.edu (dottiness.seas.harvard.edu + [140.247.52.224]) + by smtp-outbound.seas.harvard.edu (8.13.8/8.13.8) with SMTP id + nAI11Gkj008772 + for ; Tue, 17 Nov 2009 20:01:16 -0500 +Received: by dottiness.seas.harvard.edu (sSMTP sendmail emulation); + Tue, 17 Nov 2009 20:01:16 -0500 +Date: Tue, 17 Nov 2009 20:01:16 -0500 +From: Lars Kellogg-Stedman +To: notmuch +Message-ID: <20091118010116.GC25380@dottiness.seas.harvard.edu> +References: <20091118005829.GB25380@dottiness.seas.harvard.edu> +MIME-Version: 1.0 +In-Reply-To: <20091118005829.GB25380@dottiness.seas.harvard.edu> +User-Agent: Mutt/1.5.19 (2009-01-05) +Subject: Re: [notmuch] "notmuch help" outputs to stderr? +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.12 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +Content-Type: multipart/mixed; boundary="===============0848253760==" +Sender: notmuch-bounces@notmuchmail.org +Errors-To: notmuch-bounces@notmuchmail.org + + +--===============0848253760== +Content-Type: multipart/signed; micalg=pgp-sha256; + protocol="application/pgp-signature"; boundary="ZInfyf7laFu/Kiw7" +Content-Disposition: inline + + +--ZInfyf7laFu/Kiw7 +Content-Type: multipart/mixed; boundary="KdquIMZPjGJQvRdI" +Content-Disposition: inline + + +--KdquIMZPjGJQvRdI +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +> I've attached a patch that lets usage() take a FILE * argument so that +> you can output to stderr in response to usage errors, and stdout in +> response to an explicit request. + +Whoops, missed a couple of stderr's in that last patch. New one +attached. + +--=20 +Lars Kellogg-Stedman +Senior Technologist, Computing and Information Technology +Harvard University School of Engineering and Applied Sciences + + +--KdquIMZPjGJQvRdI +Content-Type: text/plain; charset=us-ascii +Content-Disposition: attachment; filename="notmuch-help.patch" +Content-Transfer-Encoding: quoted-printable + +diff --git a/notmuch.c b/notmuch.c +index c47e640..446c810 100644 +--- a/notmuch.c ++++ b/notmuch.c +@@ -157,23 +157,23 @@ command_t commands[] =3D { + }; +=20 + static void +-usage (void) ++usage (FILE *out) + { + command_t *command; + unsigned int i; +=20 +- fprintf (stderr, "Usage: notmuch [args...]\n"); +- fprintf (stderr, "\n"); +- fprintf (stderr, "Where and [args...] are as follows:\n"); +- fprintf (stderr, "\n"); ++ fprintf (out, "Usage: notmuch [args...]\n"); ++ fprintf (out, "\n"); ++ fprintf (out, "Where and [args...] are as follows:\n"); ++ fprintf (out, "\n"); +=20 + for (i =3D 0; i < ARRAY_SIZE (commands); i++) { + command =3D &commands[i]; +=20 +- fprintf (stderr, "\t%s\t%s\n\n", command->name, command->summary); ++ fprintf (out, "\t%s\t%s\n\n", command->name, command->summary); + } +=20 +- fprintf (stderr, "Use \"notmuch help \" for more details on e= +ach command.\n\n"); ++ fprintf (out, "Use \"notmuch help \" for more details on each= + command.\n\n"); + } +=20 + static int +@@ -183,8 +183,8 @@ notmuch_help_command (unused (void *ctx), int argc, cha= +r *argv[]) + unsigned int i; +=20 + if (argc =3D=3D 0) { +- fprintf (stderr, "The notmuch mail system.\n\n"); +- usage (); ++ fprintf (stdout, "The notmuch mail system.\n\n"); ++ usage (stdout); + return 0; + } +=20 +@@ -192,8 +192,8 @@ notmuch_help_command (unused (void *ctx), int argc, cha= +r *argv[]) + command =3D &commands[i]; +=20 + if (strcmp (argv[0], command->name) =3D=3D 0) { +- fprintf (stderr, "Help for \"notmuch %s\":\n\n", argv[0]); +- fprintf (stderr, "\t%s\t%s\n\n%s\n\n", command->name, ++ fprintf (stdout, "Help for \"notmuch %s\":\n\n", argv[0]); ++ fprintf (stdout, "\t%s\t%s\n\n%s\n\n", command->name, + command->summary, command->documentation); + return 0; + } + +--KdquIMZPjGJQvRdI-- + +--ZInfyf7laFu/Kiw7 +Content-Type: application/pgp-signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.9 (GNU/Linux) + +iQEcBAEBCAAGBQJLA0dcAAoJENdGlQYxQazY4nIIAIBCds86/uTmnouvyoPruUUR +Bg5mXcnjuopz1Nwotl9s9U5sGeZuZngxyEvDz1Z1aTEjwab8ndNTf1xCwIoqBs+l +i/sc4nPYubLdy1Ab/84DKVtCSbj+v5rtqhegwUWV7S1BY7t8dKNPNv7YBg7P0Azs +6s3CUxDV5eJCcxCGxxWHH8JDKRf7rDs6vzDwyPWLxlg1Xb1lEM/sRgPCKiShPdO3 +Ak2hECusjskALhSDYX8/FLMd9HwLBC13sfWuSi/pHUAIOI2jru2p5sXrVSlTnFIJ +fiMbPhKWiEaJj2kmm4pRwAhbTWp/J8ZvXWp0AyosxXQhQUWqujiyxgfiXS70SdQ= +=t3Yc +-----END PGP SIGNATURE----- + +--ZInfyf7laFu/Kiw7-- + +--===============0848253760== +Content-Type: text/plain; charset="us-ascii" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Disposition: inline + +_______________________________________________ +notmuch mailing list +notmuch@notmuchmail.org +http://notmuchmail.org/mailman/listinfo/notmuch + +--===============0848253760==-- + diff --git a/test/corpus/bar/baz/cur/25:2, b/test/corpus/bar/baz/cur/25:2, new file mode 100644 index 00000000..7378f820 --- /dev/null +++ b/test/corpus/bar/baz/cur/25:2, @@ -0,0 +1,32 @@ +From: "Stewart Smith" +To: notmuch@notmuchmail.org +Date: Wed, 18 Nov 2009 12:05:53 +1100 +Subject: [notmuch] [PATCH] Fix linking with gcc to use g++ to link in C++ + libs. +Message-ID: <1258506353-20352-1-git-send-email-stewart@flamingspork.com> + +Previously, Ubuntu 9.10, gcc 4.4.1 was getting: + +ccache gcc `pkg-config --libs glib-2.0 gmime-2.4 talloc` `xapian-config --libs` notmuch.o notmuch-config.o notmuch-dump.o notmuch-new.o notmuch-reply.o notmuch-restore.o notmuch-search.o notmuch-setup.o notmuch-show.o notmuch-tag.o notmuch-time.o gmime-filter-reply.o query-string.o show-message.o lib/notmuch.a -o notmuch +/usr/bin/ld: lib/notmuch.a(database.o): in function global constructors keyed to BOOLEAN_PREFIX_INTERNAL:database.cc(.text+0x3a): error: undefined reference to 'std::ios_base::Init::Init()' +--- + Makefile.local | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/Makefile.local b/Makefile.local +index f824bed..dbd3e20 100644 +--- a/Makefile.local ++++ b/Makefile.local +@@ -18,7 +18,7 @@ notmuch_client_srcs = \ + + notmuch_client_modules = $(notmuch_client_srcs:.c=.o) + notmuch: $(notmuch_client_modules) lib/notmuch.a +- $(CC) $(LDFLAGS) $^ -o $@ ++ $(CXX) $(LDFLAGS) $^ -o $@ + + notmuch.1.gz: + gzip --stdout notmuch.1 > notmuch.1.gz +-- +1.6.3.3 + + diff --git a/test/corpus/bar/baz/cur/26:2, b/test/corpus/bar/baz/cur/26:2, new file mode 100644 index 00000000..f3c5f53d --- /dev/null +++ b/test/corpus/bar/baz/cur/26:2, @@ -0,0 +1,121 @@ +From: "Stewart Smith" +To: notmuch@notmuchmail.org +Date: Wed, 18 Nov 2009 12:56:40 +1100 +Subject: [notmuch] [PATCH 2/2] Read mail directory in inode number order +Message-ID: <1258509400-32511-1-git-send-email-stewart@flamingspork.com> + +This gives a rather decent reduction in number of seeks required when +reading a Maildir that isn't in pagecache. + +Most filesystems give some locality on disk based on inode numbers. +In ext[234] this is the inode tables, in XFS groups of sequential inode +numbers are together on disk and the most significant bits indicate +allocation group (i.e inode 1,000,000 is always after inode 1,000). + +With this patch, we read in the whole directory, sort by inode number +before stat()ing the contents. + +Ideally, directory is sequential and then we make one scan through the +file system stat()ing. + +Since the universe is not ideal, we'll probably seek during reading the +directory and a fair bit while reading the inodes themselves. + +However... with readahead, and stat()ing in inode order, we should be +in the best place possible to hit the cache. + +In a (not very good) benchmark of "how long does it take to find the first +15,000 messages in my Maildir after 'echo 3 > /proc/sys/vm/drop_caches'", +this patch consistently cut at least 8 seconds off the scan time. + +Without patch: 50 seconds +With patch: 38-42 seconds. + +(I did this in a previous maildir reading project and saw large improvements too) +--- + notmuch-new.c | 32 +++++++++++++++----------------- + 1 files changed, 15 insertions(+), 17 deletions(-) + +diff --git a/notmuch-new.c b/notmuch-new.c +index 83a05ba..11fad8c 100644 +--- a/notmuch-new.c ++++ b/notmuch-new.c +@@ -73,6 +73,11 @@ add_files_print_progress (add_files_state_t *state) + fflush (stdout); + } + ++static int ino_cmp(const struct dirent **a, const struct dirent **b) ++{ ++ return ((*a)->d_ino < (*b)->d_ino)? -1: 1; ++} ++ + /* Examine 'path' recursively as follows: + * + * o Ask the filesystem for the mtime of 'path' (path_mtime) +@@ -100,13 +105,12 @@ add_files_recursive (notmuch_database_t *notmuch, + add_files_state_t *state) + { + DIR *dir = NULL; +- struct dirent *e, *entry = NULL; +- int entry_length; +- int err; ++ struct dirent *entry = NULL; + char *next = NULL; + time_t path_mtime, path_dbtime; + notmuch_status_t status, ret = NOTMUCH_STATUS_SUCCESS; + notmuch_message_t *message = NULL; ++ struct dirent **namelist = NULL; + + /* If we're told to, we bail out on encountering a read-only + * directory, (with this being a clear clue from the user to +@@ -122,31 +126,23 @@ add_files_recursive (notmuch_database_t *notmuch, + path_mtime = st->st_mtime; + + path_dbtime = notmuch_database_get_timestamp (notmuch, path); ++ int n_entries= scandir(path, &namelist, 0, ino_cmp); + +- dir = opendir (path); +- if (dir == NULL) { ++ if (n_entries == -1) { + fprintf (stderr, "Error opening directory %s: %s\n", + path, strerror (errno)); + ret = NOTMUCH_STATUS_FILE_ERROR; + goto DONE; + } + +- entry_length = offsetof (struct dirent, d_name) + +- pathconf (path, _PC_NAME_MAX) + 1; +- entry = malloc (entry_length); ++ int i=0; + + while (!interrupted) { +- err = readdir_r (dir, entry, &e); +- if (err) { +- fprintf (stderr, "Error reading directory: %s\n", +- strerror (errno)); +- ret = NOTMUCH_STATUS_FILE_ERROR; +- goto DONE; +- } +- +- if (e == NULL) ++ if (i == n_entries) + break; + ++ entry= namelist[i++]; ++ + /* If this directory hasn't been modified since the last + * add_files, then we only need to look further for + * sub-directories. */ +@@ -243,6 +239,8 @@ add_files_recursive (notmuch_database_t *notmuch, + free (entry); + if (dir) + closedir (dir); ++ if (namelist) ++ free (namelist); + + return ret; + } +-- +1.6.3.3 + + diff --git a/test/corpus/bar/baz/new/27:2, b/test/corpus/bar/baz/new/27:2, new file mode 100644 index 00000000..7f0f045b --- /dev/null +++ b/test/corpus/bar/baz/new/27:2, @@ -0,0 +1,21 @@ +From: "Keith Packard" +To: notmuch@notmuchmail.org +Date: Tue, 17 Nov 2009 17:59:49 -0800 +Subject: [notmuch] New to the list +In-Reply-To: <1258498485-sup-142@elly> +References: <1258498485-sup-142@elly> +Message-ID: + +On Tue, 17 Nov 2009 23:57:18 +0100, Israel Herraiz wrote: + +> "Not much" sounds interesting, and I wonder whether it could be +> integrated with the views of Sup (inbox, threads, etc). So I have +> subscribed to the list to keep an eye on what's going on here. + +We've tried to clone much of the sup UI inside emacs, including the +inbox and threaded message presentation. Of course, we had to "improve" +it a bit, as much due to the differences between curses and emacs as due +to personal preferences... + +-keith + diff --git a/test/corpus/bar/baz/new/28:2, b/test/corpus/bar/baz/new/28:2, new file mode 100644 index 00000000..83ce01bd --- /dev/null +++ b/test/corpus/bar/baz/new/28:2, @@ -0,0 +1,38 @@ +From: "Keith Packard" +To: notmuch@notmuchmail.org +Date: Tue, 17 Nov 2009 18:03:17 -0800 +Subject: [notmuch] Introducing myself +In-Reply-To: <20091118002059.067214ed@hikari> +References: <20091118002059.067214ed@hikari> +Message-ID: + +On Wed, 18 Nov 2009 00:20:59 +0100, Adrian Perez de Castro wrote: + +> Some time ago I thought +> about doing something like Not Much and in fact I played a bit with the +> Python+Xapian and the Python+Whoosh combinations, because I find relaxing +> to code things in Python when I am not working and also it is installed +> by default on most distribution. I got to have some mailboxes indexed and +> basic searching working a couple of months ago. + +Sup certainly started a lot of people thinking... + +> Also, I would like to share one idea I had in mind, that you might find +> interesting: One thing I have found very annoying is having to re-tag my +> mail when the indexes get b0rked (it happened a couple of times to me while +> using Sup), so I was planning to mails as read/unread and adding the tags +> not just to the index, but to the mail text itself, e.g. by adding a +> "X-Tags" header field or by reusing the "Keywords" one. + +Easier than that, notmuch (and sup too), provide a 'dump' command which +just lists all of the message IDs and their associated tags. Makes +saving tags easy and doesn't involve rewriting messages. I do this once +a day just before my computer is backed up to an external drive. + +If the index is destroyed, you can reindex the messages and then reapply +all of the tags with 'notmuch restore'. + +-- +keith.packard at intel.com + + -- cgit v1.2.3