Re: v4 of Hex Dump/Restore patches
authorMark Walters <markwalters1009@gmail.com>
Sat, 8 Dec 2012 19:47:16 +0000 (19:47 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:51:50 +0000 (09:51 -0800)
b7/c101d26901c2387a032646691e80b1650f2109 [new file with mode: 0644]

diff --git a/b7/c101d26901c2387a032646691e80b1650f2109 b/b7/c101d26901c2387a032646691e80b1650f2109
new file mode 100644 (file)
index 0000000..66e6df5
--- /dev/null
@@ -0,0 +1,408 @@
+Return-Path: <m.walters@qmul.ac.uk>\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 5DBD6431FAF\r
+       for <notmuch@notmuchmail.org>; Sat,  8 Dec 2012 11:47:18 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.098\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
+       tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+       NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 uqFfCLLK1mvH for <notmuch@notmuchmail.org>;\r
+       Sat,  8 Dec 2012 11:47:16 -0800 (PST)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id B8600431FAE\r
+       for <notmuch@notmuchmail.org>; Sat,  8 Dec 2012 11:47:15 -0800 (PST)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+       by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+       (envelope-from <m.walters@qmul.ac.uk>)\r
+       id 1ThQMj-0005rF-AY; Sat, 08 Dec 2012 19:47:14 +0000\r
+Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)\r
+       by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
+       (envelope-from <m.walters@qmul.ac.uk>)\r
+       id 1ThQMi-0000rJ-Jp; Sat, 08 Dec 2012 19:47:13 +0000\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: david@tethera.net, notmuch@notmuchmail.org\r
+Subject: Re: v4 of Hex Dump/Restore patches\r
+In-Reply-To: <1354979276-20099-1-git-send-email-david@tethera.net>\r
+References: <1354979276-20099-1-git-send-email-david@tethera.net>\r
+User-Agent: Notmuch/0.14+155~g7edfdc3 (http://notmuchmail.org) Emacs/23.4.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Sat, 08 Dec 2012 19:47:16 +0000\r
+Message-ID: <87a9totjgb.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Sender-Host-Address: 93.97.24.31\r
+X-QM-SPAM-Info: Sender has good ham record.  :)\r
+X-QM-Body-MD5: 22e3bd8bc3c156dd0519c13bc310c7e8 (of first 20000 bytes)\r
+X-SpamAssassin-Score: -1.8\r
+X-SpamAssassin-SpamBar: -\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+       determine if it is\r
+       spam. We require at least 5.0 points to mark a message as spam.\r
+       This message scored -1.8 points.\r
+       Summary of the scoring: \r
+       * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
+       *      medium trust\r
+       *      [138.37.6.40 listed in list.dnswl.org]\r
+       * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+       provider *      (markwalters1009[at]gmail.com)\r
+       *  0.5 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\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: Sat, 08 Dec 2012 19:47:18 -0000\r
+\r
+\r
+Aside from the minor nit with one comment this series looks good to\r
+me. (I haven't thoroughly checked patch 8)\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+On Sat, 08 Dec 2012, david@tethera.net wrote:\r
+> This obsoletes the series at\r
+>      \r
+>      id:1354843607-17980-1-git-send-email-david@tethera.net\r
+>\r
+> One new patch:\r
+>\r
+> [Patch v4 08/10] test/dump-restore: add test for warning/error\r
+>\r
+> Other changes since the last series are as follows:\r
+>\r
+> commit 16ca0f8126fafd49266ffa02534f2e9b73c03027\r
+> Author: David Bremner <bremner@debian.org>\r
+> Date:   Fri Dec 7 20:19:21 2012 -0400\r
+>\r
+>     fixup for test/dump-restore\r
+>\r
+> diff --git a/test/dump-restore b/test/dump-restore\r
+> index 2532cbb..b267792 100755\r
+> --- a/test/dump-restore\r
+> +++ b/test/dump-restore\r
+> @@ -212,7 +212,7 @@ test_expect_equal_file EXPECTED OUTPUT\r
+>  \r
+>  test_begin_subtest 'roundtripping random message-ids and tags'\r
+>  \r
+> -    ${TEST_DIRECTORY}/random-corpus --config-path=${NOTMUCH_CONFIG}\r
+> +    ${TEST_DIRECTORY}/random-corpus --config-path=${NOTMUCH_CONFIG} \\r
+>                      --num-messages=100\r
+>  \r
+>       notmuch dump --format=batch-tag| \\r
+>\r
+> commit 9d864bd724bd2d2b26b5d52e3e2f28b4fff2046f\r
+> Author: David Bremner <bremner@debian.org>\r
+> Date:   Fri Dec 7 20:32:50 2012 -0400\r
+>\r
+>     fixup for tag-util.c: put * in right palce\r
+>\r
+> diff --git a/tag-util.h b/tag-util.h\r
+> index df05d72..6674674 100644\r
+> --- a/tag-util.h\r
+> +++ b/tag-util.h\r
+> @@ -62,8 +62,8 @@ parse_tag_line (void *ctx, char *line,\r
+>   * ctx is passed to talloc\r
+>   */\r
+>  \r
+> -tag_op_list_t\r
+> -*tag_op_list_create (void *ctx);\r
+> +tag_op_list_t *\r
+> +tag_op_list_create (void *ctx);\r
+>  \r
+>  /*\r
+>   * Add a tag operation (delete iff remove == TRUE) to a list.\r
+>\r
+> commit d2cead797981e8992849e1d96ad95177b42290e2\r
+> Author: David Bremner <bremner@debian.org>\r
+> Date:   Fri Dec 7 20:57:52 2012 -0400\r
+>\r
+>     fixup for id:87txrxxyzp.fsf@nikula.org\r
+>\r
+> diff --git a/tag-util.c b/tag-util.c\r
+> index 3d54e9e..a927363 100644\r
+> --- a/tag-util.c\r
+> +++ b/tag-util.c\r
+> @@ -24,9 +24,15 @@ parse_tag_line (void *ctx, char *line,\r
+>  {\r
+>      char *tok = line;\r
+>      size_t tok_len = 0;\r
+> -    char *line_for_error = talloc_strdup (ctx, line);\r
+> +    char *line_for_error;\r
+>      int ret = 0;\r
+>  \r
+> +    line_for_error = talloc_strdup (ctx, line);\r
+> +    if (line_for_error == NULL) {\r
+> +    fprintf (stderr, "Error: out of memory\n");\r
+> +    return -1;\r
+> +    }\r
+> +\r
+>      chomp_newline (line);\r
+>  \r
+>      /* remove leading space */\r
+> @@ -58,7 +64,7 @@ parse_tag_line (void *ctx, char *line,\r
+>  \r
+>      /* If tag is terminated by NUL, there's no query string. */\r
+>      if (*(tok + tok_len) == '\0') {\r
+> -        fprintf (stderr, "no query string: %s\n", line_for_error);\r
+> +        fprintf (stderr, "Warning: no query string: %s\n", line_for_error);\r
+>          ret = 1;\r
+>          goto DONE;\r
+>      }\r
+> @@ -71,19 +77,21 @@ parse_tag_line (void *ctx, char *line,\r
+>  \r
+>      /* Maybe refuse empty tags. */\r
+>      if (! (flags & TAG_FLAG_BE_GENEROUS) && *tag == '\0') {\r
+> -        fprintf (stderr, "Error: empty tag: %s\n", line_for_error);\r
+> +        fprintf (stderr, "Warning: empty tag: %s\n", line_for_error);\r
+> +        ret = 1;\r
+>          goto DONE;\r
+>      }\r
+>  \r
+>      /* Decode tag. */\r
+>      if (hex_decode_inplace (tag) != HEX_SUCCESS) {\r
+> -        fprintf (stderr, "Hex decoding of tag %s failed\n",\r
+> +        fprintf (stderr, "Warning: Hex decoding of tag %s failed\n",\r
+>                   tag);\r
+>          ret = 1;\r
+>          goto DONE;\r
+>      }\r
+>  \r
+>      if (tag_op_list_append (ctx, tag_ops, tag, remove)) {\r
+> +        /* diagnostics already printed */\r
+>          ret = -1;\r
+>          goto DONE;\r
+>      }\r
+> @@ -98,7 +106,7 @@ parse_tag_line (void *ctx, char *line,\r
+>  \r
+>      /* tok now points to the query string */\r
+>      if (hex_decode_inplace (tok) != HEX_SUCCESS) {\r
+> -    fprintf (stderr, "Hex decoding of query %s failed\n",\r
+> +    fprintf (stderr, "Warning: Hex decoding of query %s failed\n",\r
+>               tok);\r
+>      ret = 1;\r
+>      goto DONE;\r
+>\r
+> commit 162c20ab6d9b9eef56cb2b966a7144a61557eade\r
+> Author: David Bremner <bremner@debian.org>\r
+> Date:   Sat Dec 8 07:29:56 2012 -0400\r
+>\r
+>     fixup for id:87624chmfw.fsf@qmul.ac.uk\r
+>     \r
+>     update comment\r
+>\r
+> diff --git a/util/string-util.h b/util/string-util.h\r
+> index 696da40..ac7676c 100644\r
+> --- a/util/string-util.h\r
+> +++ b/util/string-util.h\r
+> @@ -3,7 +3,10 @@\r
+>  \r
+>  #include <string.h>\r
+>  \r
+> -/* like strtok(3), but without state, and doesn't modify s. usage pattern:\r
+> +/* like strtok(3), but without state, and doesn't modify s.  Return\r
+> + * value is indicated by pointer and length, not null terminator.\r
+> + *\r
+> + * Usage pattern:\r
+>   *\r
+>   * const char *tok = input;\r
+>   * const char *delim = " \t";\r
+>\r
+> commit 590adeec072f235861154b930bfb10bedbe37e8a\r
+> Author: David Bremner <bremner@debian.org>\r
+> Date:   Sat Dec 8 07:42:44 2012 -0400\r
+>\r
+>     fixup for id:8738zghl6d.fsf@qmul.ac.uk\r
+>\r
+> diff --git a/tag-util.c b/tag-util.c\r
+> index a927363..c97d240 100644\r
+> --- a/tag-util.c\r
+> +++ b/tag-util.c\r
+> @@ -98,8 +98,6 @@ parse_tag_line (void *ctx, char *line,\r
+>      }\r
+>  \r
+>      if (tok == NULL) {\r
+> -    fprintf (stderr, "Warning: Ignoring invalid input line: %s\n",\r
+> -             line_for_error);\r
+>      ret = 1;\r
+>      goto DONE;\r
+>      }\r
+> @@ -113,7 +111,13 @@ parse_tag_line (void *ctx, char *line,\r
+>      }\r
+>  \r
+>      *query_string = tok;\r
+> +\r
+>    DONE:\r
+> +    if (ret != 0)\r
+> +    fprintf (stderr, "% invalid input line %s\n",\r
+> +             ret == 1 ? "Warning: Ignoring" : "Error: Failing at",\r
+> +             line_for_error);\r
+> +\r
+>      talloc_free (line_for_error);\r
+>      return ret;\r
+>  }\r
+>\r
+> commit 6002e08eb048612f5ef4eab3205a2887e1ab3f02\r
+> Author: David Bremner <bremner@debian.org>\r
+> Date:   Sat Dec 8 07:46:39 2012 -0400\r
+>\r
+>     fixup: chomp line before copy\r
+>\r
+> diff --git a/tag-util.c b/tag-util.c\r
+> index c97d240..8e6b1ef 100644\r
+> --- a/tag-util.c\r
+> +++ b/tag-util.c\r
+> @@ -27,14 +27,14 @@ parse_tag_line (void *ctx, char *line,\r
+>      char *line_for_error;\r
+>      int ret = 0;\r
+>  \r
+> +    chomp_newline (line);\r
+> +\r
+>      line_for_error = talloc_strdup (ctx, line);\r
+>      if (line_for_error == NULL) {\r
+>      fprintf (stderr, "Error: out of memory\n");\r
+>      return -1;\r
+>      }\r
+>  \r
+> -    chomp_newline (line);\r
+> -\r
+>      /* remove leading space */\r
+>      while (*tok == ' ' || *tok == '\t')\r
+>      tok++;\r
+>\r
+> commit 9c4878bf0ad0e1f60a45c963998a20635fc234af\r
+> Author: David Bremner <bremner@debian.org>\r
+> Date:   Sat Dec 8 08:36:48 2012 -0400\r
+>\r
+>     further fixup for error messages\r
+>\r
+> diff --git a/tag-util.c b/tag-util.c\r
+> index 8e6b1ef..6018d49 100644\r
+> --- a/tag-util.c\r
+> +++ b/tag-util.c\r
+> @@ -41,7 +41,7 @@ parse_tag_line (void *ctx, char *line,\r
+>  \r
+>      /* Skip empty and comment lines. */\r
+>      if (*tok == '\0' || *tok == '#') {\r
+> -    ret = 1;\r
+> +    ret = 2;\r
+>      goto DONE;\r
+>      }\r
+>  \r
+> @@ -55,6 +55,8 @@ parse_tag_line (void *ctx, char *line,\r
+>      /* Optional explicit end of tags marker. */\r
+>      if (tok_len == 2 && strncmp (tok, "--", tok_len) == 0) {\r
+>          tok = strtok_len (tok + tok_len, " ", &tok_len);\r
+> +        if (tok == NULL)\r
+> +            fprintf (stderr, "Warning: no query string: %s\n", line_for_error);\r
+>          break;\r
+>      }\r
+>  \r
+> @@ -113,8 +115,8 @@ parse_tag_line (void *ctx, char *line,\r
+>      *query_string = tok;\r
+>  \r
+>    DONE:\r
+> -    if (ret != 0)\r
+> -    fprintf (stderr, "% invalid input line %s\n",\r
+> +    if ((ret % 2) != 0)\r
+> +    fprintf (stderr, "%s invalid input line %s\n",\r
+>               ret == 1 ? "Warning: Ignoring" : "Error: Failing at",\r
+>               line_for_error);\r
+>  \r
+> diff --git a/tag-util.h b/tag-util.h\r
+> index 6674674..1d564f0 100644\r
+> --- a/tag-util.h\r
+> +++ b/tag-util.h\r
+> @@ -45,7 +45,10 @@ typedef enum {\r
+>   * Leading and trailing space ' ' is ignored. Empty lines and lines\r
+>   * beginning with '#' are ignored.\r
+>   *\r
+> - * Returns: 0 for OK, 1 for skipped line, -1 for fatal(ish) error.\r
+> + * Returns: 0       OK,\r
+> + *          1       skipped (invalid) line\r
+> + *          2       skipped (valid)\r
+> + *          -1      fatal(ish) error.\r
+>   *\r
+>   * Output Parameters:\r
+>   *  ops     contains a list of tag operations\r
+>\r
+> commit 6e8a7b30e3980f77724d6005292265d49ad5241a\r
+> Author: David Bremner <bremner@debian.org>\r
+> Date:   Sat Dec 8 08:41:01 2012 -0400\r
+>\r
+>     fixup for id:87wqwsg46p.fsf@qmul.ac.uk\r
+>\r
+> diff --git a/notmuch-restore.c b/notmuch-restore.c\r
+> index ceec2d3..44bf88d 100644\r
+> --- a/notmuch-restore.c\r
+> +++ b/notmuch-restore.c\r
+> @@ -56,6 +56,11 @@ tag_message (unused (void *ctx),\r
+>      return ret;\r
+>  }\r
+>  \r
+> +/* Sup dump output is one line per message. We match a sequence of\r
+> + * non-space characters for the message-id, then one or more\r
+> + * spaces, then a list of space-separated tags as a sequence of\r
+> + * characters within literal '(' and ')'. */\r
+> +\r
+>  static int\r
+>  parse_sup_line (void *ctx, char *line,\r
+>              char **query_str, tag_op_list_t *tag_ops)\r
+> @@ -172,11 +177,6 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])\r
+>               argv[opt_index]);\r
+>      return 1;\r
+>      }\r
+> -\r
+> -    /* Dump output is one line per message. We match a sequence of\r
+> -     * non-space characters for the message-id, then one or more\r
+> -     * spaces, then a list of space-separated tags as a sequence of\r
+> -     * characters within literal '(' and ')'. */\r
+>      char *p;\r
+>  \r
+>      line_len = getline (&line, &line_size, input);\r
+>\r
+> commit ee198b0d388243f0f43fab1d7ef7acbea5bdb3e6\r
+> Author: David Bremner <bremner@debian.org>\r
+> Date:   Sat Dec 8 08:52:51 2012 -0400\r
+>\r
+>     fixup: rewrite confusing for loop as while.\r
+>\r
+> diff --git a/tag-util.c b/tag-util.c\r
+> index 6018d49..b68ea50 100644\r
+> --- a/tag-util.c\r
+> +++ b/tag-util.c\r
+> @@ -157,8 +157,10 @@ makes_changes (notmuch_message_t *message,\r
+>      const char *cur_tag = notmuch_tags_get (tags);\r
+>      int last_op =  (flags & TAG_FLAG_REMOVE_ALL) ? -1 : 0;\r
+>  \r
+> -    /* slight contortions to count down with an unsigned index */\r
+> -    for (i = list->count; i-- > 0; /*nothing*/) {\r
+> +    /* scan backwards to get last operation */\r
+> +    i = list->count;\r
+> +    while (i > 0) {\r
+> +        i--;\r
+>          if (strcmp (cur_tag, list->ops[i].tag) == 0) {\r
+>              last_op = list->ops[i].remove ? -1 : 1;\r
+>              break;\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r