From 8b7e6a1ae6525409233c9d241f0dee0e555c86e4 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Tue, 7 Apr 2015 08:24:43 +0100 Subject: [PATCH] Re: [Patch v2 4/4] cli: add standard option processing to config and setup --- 60/cad34d40879a162459ffe6576a9533c9971186 | 188 ++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 60/cad34d40879a162459ffe6576a9533c9971186 diff --git a/60/cad34d40879a162459ffe6576a9533c9971186 b/60/cad34d40879a162459ffe6576a9533c9971186 new file mode 100644 index 000000000..66b7ca219 --- /dev/null +++ b/60/cad34d40879a162459ffe6576a9533c9971186 @@ -0,0 +1,188 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 5EE036DE1983 + for ; Tue, 7 Apr 2015 00:24:57 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -1.688 +X-Spam-Level: +X-Spam-Status: No, score=-1.688 tagged_above=-999 required=5 + tests=[AWL=-0.040, DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3, + RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, + RP_MATCHES_RCVD=-0.55, T_FREEMAIL_FORGED_FROMDOMAIN=0.01, + T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id WTTvKfUFniH4 for ; + Tue, 7 Apr 2015 00:24:55 -0700 (PDT) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + by arlo.cworth.org (Postfix) with ESMTPS id D84D46DE1974 + for ; Tue, 7 Apr 2015 00:24:54 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1YfNsR-000616-L0; Tue, 07 Apr 2015 08:24:52 +0100 +Received: from 188.29.19.158.threembb.co.uk ([188.29.19.158] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) + (envelope-from ) + id 1YfNsQ-00070m-5z; Tue, 07 Apr 2015 08:24:51 +0100 +From: Mark Walters +To: David Bremner , David Bremner , + notmuch@notmuchmail.org +Subject: Re: [Patch v2 4/4] cli: add standard option processing to config and + setup +In-Reply-To: <1428322958-2887-5-git-send-email-david@tethera.net> +References: <87d23ixnr7.fsf@maritornes.cs.unb.ca> + <1428322958-2887-1-git-send-email-david@tethera.net> + <1428322958-2887-5-git-send-email-david@tethera.net> +User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Tue, 07 Apr 2015 08:24:43 +0100 +Message-ID: <87vbh8qu2s.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-QM-SPAM-Info: 188.29.19.158 is in Janet mirror of Spamhaus XBL; + see http://www.spamhaus.org/xbl/ +X-Sender-Host-Address: 188.29.19.158 +X-QM-Geographic: According to ripencc, + this message was delivered by a machine in Britain (UK) (GB). +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: 60c409073c636466411aa8b2036c8bf0 (of first 20000 bytes) +X-SpamAssassin-Score: -0.1 +X-SpamAssassin-SpamBar: / +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -0.1 points. + Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider + * (markwalters1009[at]gmail.com) + * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay + * domain + * -0.1 AWL AWL: Adjusted score from AWL reputation of From: address +X-QM-Scan-Virus: ClamAV says the message is clean +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Tue, 07 Apr 2015 07:24:57 -0000 + + +Hi + +On Mon, 06 Apr 2015, David Bremner wrote: +> In particular this fixes a recently encountered bug where the +> "--config" argument to "notmuch setup" is silently ignored, which the +> unpleasant consequence of overwriting the users config file. +> --- +> notmuch-config.c | 16 +++++++++++++++- +> notmuch-setup.c | 12 ++++++++++++ +> test/random-corpus.c | 9 +++++++++ +> 3 files changed, 36 insertions(+), 1 deletion(-) +> +> diff --git a/notmuch-config.c b/notmuch-config.c +> index 2d5c297..f2cd6a8 100644 +> --- a/notmuch-config.c +> +++ b/notmuch-config.c +> @@ -872,8 +872,22 @@ int +> notmuch_config_command (notmuch_config_t *config, int argc, char *argv[]) +> { +> int ret; +> + int opt_index; +> +> - argc--; argv++; /* skip subcommand argument */ +> + notmuch_opt_desc_t options[] = { +> + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, +> + { 0, 0, 0, 0, 0 } +> + }; +> + +> + opt_index = parse_arguments (argc, argv, options, 1); +> + if (opt_index < 0) +> + return EXIT_FAILURE; +> + +> + notmuch_process_shared_options (argv[0]); +> + +> + /* skip at least subcommand argument */ +> + argc-= opt_index; +> + argv+= opt_index; +> +> if (argc < 1) { +> fprintf (stderr, "Error: notmuch config requires at least one argument.\n"); +> diff --git a/notmuch-setup.c b/notmuch-setup.c +> index 36a6171..6a020dc 100644 +> --- a/notmuch-setup.c +> +++ b/notmuch-setup.c +> @@ -133,6 +133,7 @@ notmuch_setup_command (notmuch_config_t *config, +> size_t new_tags_len; +> const char **search_exclude_tags; +> size_t search_exclude_tags_len; +> + int opt_index; +> +> #define prompt(format, ...) \ +> do { \ +> @@ -145,6 +146,17 @@ notmuch_setup_command (notmuch_config_t *config, +> chomp_newline (response); \ +> } while (0) +> +> + notmuch_opt_desc_t options[] = { +> + { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, +> + { 0, 0, 0, 0, 0 } +> + }; +> + +> + opt_index = parse_arguments (argc, argv, options, 1); +> + if (opt_index < 0) +> + return EXIT_FAILURE; +> + +> + notmuch_process_shared_options ("setup"); + +Why "setup" here rather than argv[0] or similar? It seems inconsistent +with the other cases. + +Best wishes + +Mark + + + +> + +> if (notmuch_config_is_new (config)) +> welcome_message_pre_setup (); +> +> diff --git a/test/random-corpus.c b/test/random-corpus.c +> index 790193d..6c467bb 100644 +> --- a/test/random-corpus.c +> +++ b/test/random-corpus.c +> @@ -114,6 +114,15 @@ random_utf8_string (void *ctx, size_t char_count) +> return buf; +> } +> +> +/* stubs since we cannot link with notmuch.o */ +> +const notmuch_opt_desc_t notmuch_shared_options[] = { +> + { 0, 0, 0, 0, 0 } +> +}; +> + +> +void +> +notmuch_process_shared_options (unused (const char *dummy)) +> +{ +> +} +> +> int +> main (int argc, char **argv) +> -- +> 2.1.4 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2