Re: [PATCH] create .mailmap file (for git shortlog/blame)
[notmuch-archives.git] / 18 / e4b2de52eeff304e64798bd3f5f2cee1478725
1 Return-Path: <jani@nikula.org>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 468C4431FC2\r
6         for <notmuch@notmuchmail.org>; Mon,  3 Dec 2012 12:56:24 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
9 X-Spam-Flag: NO\r
10 X-Spam-Score: -0.7\r
11 X-Spam-Level: \r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
13         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id Yo1m3Mo5gv9B for <notmuch@notmuchmail.org>;\r
17         Mon,  3 Dec 2012 12:56:23 -0800 (PST)\r
18 Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com\r
19         [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id D7261431FB6\r
22         for <notmuch@notmuchmail.org>; Mon,  3 Dec 2012 12:56:22 -0800 (PST)\r
23 Received: by mail-lb0-f181.google.com with SMTP id ge1so2880376lbb.26\r
24         for <notmuch@notmuchmail.org>; Mon, 03 Dec 2012 12:56:21 -0800 (PST)\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
26         d=google.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references\r
28         :in-reply-to:references:x-gm-message-state;\r
29         bh=WjieLvL5Vvd+DqOJBp48Ahgr3TtkaU0A1c8O5KtgoNw=;\r
30         b=PPYyYFc2jVtb5UYSbao7TPoyQ7Hj2DNcnkTGrOXJETp7BSxRGnlqofDoqnU34trzEx\r
31         h4h8SZnBQCIoDsrx8Q8Ifhzf0G23/XJRjeoGF72sHCQmpirrf6lK0BZsBDeWTylNfYlj\r
32         7cbSXPwtKsLqwsYQ7fu3/dGd5DDqwESCLcXNwP6VSqtl0UiPFDJXQSaJa5t290xaMa3W\r
33         1OVOCtS3Q5aMOy4XvSVkm6iFGch+ObsZIkINip/9gzdKACVuO+hutIwUnw/Dxa8/Pk+9\r
34         4lrN82ipBKt2GXAKt/bAScMzpdlYSHOdGC/cLPRoQWkgcgjyrZK455yGxdIu0Sspd9zM\r
35         BCrg==\r
36 Received: by 10.152.124.111 with SMTP id mh15mr10745675lab.20.1354568181018;\r
37         Mon, 03 Dec 2012 12:56:21 -0800 (PST)\r
38 Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi.\r
39         [80.223.81.27])\r
40         by mx.google.com with ESMTPS id oj5sm5824688lab.8.2012.12.03.12.56.19\r
41         (version=SSLv3 cipher=OTHER); Mon, 03 Dec 2012 12:56:20 -0800 (PST)\r
42 From: Jani Nikula <jani@nikula.org>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH 2/2] cli: convert "notmuch new" to the argument parser\r
45 Date: Mon,  3 Dec 2012 22:56:13 +0200\r
46 Message-Id:\r
47  <e31ac6b2ceed533f8ac5386a010f4c052e09502e.1354568072.git.jani@nikula.org>\r
48 X-Mailer: git-send-email 1.7.10.4\r
49 In-Reply-To:\r
50  <c4f2a1048763950dd14e13c99a4e7eb333be8c9d.1354568072.git.jani@nikula.org>\r
51 References:\r
52  <c4f2a1048763950dd14e13c99a4e7eb333be8c9d.1354568072.git.jani@nikula.org>\r
53 In-Reply-To:\r
54  <c4f2a1048763950dd14e13c99a4e7eb333be8c9d.1354568072.git.jani@nikula.org>\r
55 References:\r
56  <c4f2a1048763950dd14e13c99a4e7eb333be8c9d.1354568072.git.jani@nikula.org>\r
57 X-Gm-Message-State:\r
58  ALoCoQlRUscPPEoj3fx6iEattPNM0qaNTLfIQi5m5rCg3+1SIq1luy50k2cJWlIoiIY0C0DoB2xj\r
59 X-BeenThere: notmuch@notmuchmail.org\r
60 X-Mailman-Version: 2.1.13\r
61 Precedence: list\r
62 List-Id: "Use and development of the notmuch mail system."\r
63         <notmuch.notmuchmail.org>\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
65         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
67 List-Post: <mailto:notmuch@notmuchmail.org>\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
71 X-List-Received-Date: Mon, 03 Dec 2012 20:56:24 -0000\r
72 \r
73 Use the notmuch argument parser to handle arguments in "notmuch\r
74 new". As a side effect, this fixes broken STRNCMP_LITERAL usage that\r
75 accepts, for example, --verbosefoo for --verbose.\r
76 ---\r
77  notmuch-new.c |   38 +++++++++++++++++++-------------------\r
78  1 file changed, 19 insertions(+), 19 deletions(-)\r
79 \r
80 diff --git a/notmuch-new.c b/notmuch-new.c\r
81 index 718a538..feb9c32 100644\r
82 --- a/notmuch-new.c\r
83 +++ b/notmuch-new.c\r
84 @@ -36,8 +36,8 @@ typedef struct _filename_list {\r
85  \r
86  typedef struct {\r
87      int output_is_a_tty;\r
88 -    int verbose;\r
89 -    int debug;\r
90 +    notmuch_bool_t verbose;\r
91 +    notmuch_bool_t debug;\r
92      const char **new_tags;\r
93      size_t new_tags_length;\r
94      const char **new_ignore;\r
95 @@ -853,28 +853,28 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
96      char *dot_notmuch_path;\r
97      struct sigaction action;\r
98      _filename_node_t *f;\r
99 +    int opt_index;\r
100      int i;\r
101      notmuch_bool_t timer_is_active = FALSE;\r
102 -    notmuch_bool_t run_hooks = TRUE;\r
103 +    notmuch_bool_t no_hooks = FALSE;\r
104  \r
105 -    add_files_state.verbose = 0;\r
106 -    add_files_state.debug = 0;\r
107 +    add_files_state.verbose = FALSE;\r
108 +    add_files_state.debug = FALSE;\r
109      add_files_state.output_is_a_tty = isatty (fileno (stdout));\r
110  \r
111 -    argc--; argv++; /* skip subcommand argument */\r
112 +    notmuch_opt_desc_t options[] = {\r
113 +       { NOTMUCH_OPT_BOOLEAN,  &add_files_state.verbose, "verbose", 'v', 0 },\r
114 +       { NOTMUCH_OPT_BOOLEAN,  &add_files_state.debug, "debug", 'd', 0 },\r
115 +       { NOTMUCH_OPT_BOOLEAN,  &no_hooks, "no-hooks", 'n', 0 },\r
116 +       { 0, 0, 0, 0, 0 }\r
117 +    };\r
118  \r
119 -    for (i = 0; i < argc && argv[i][0] == '-'; i++) {\r
120 -       if (STRNCMP_LITERAL (argv[i], "--verbose") == 0) {\r
121 -           add_files_state.verbose = 1;\r
122 -       } else if (strcmp (argv[i], "--debug") == 0) {\r
123 -           add_files_state.debug = 1;\r
124 -       } else if (strcmp (argv[i], "--no-hooks") == 0) {\r
125 -           run_hooks = FALSE;\r
126 -       } else {\r
127 -           fprintf (stderr, "Unrecognized option: %s\n", argv[i]);\r
128 -           return 1;\r
129 -       }\r
130 +    opt_index = parse_arguments (argc, argv, options, 1);\r
131 +    if (opt_index < 0) {\r
132 +       /* diagnostics already printed */\r
133 +       return 1;\r
134      }\r
135 +\r
136      config = notmuch_config_open (ctx, NULL, NULL);\r
137      if (config == NULL)\r
138         return 1;\r
139 @@ -884,7 +884,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
140      add_files_state.synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);\r
141      db_path = notmuch_config_get_database_path (config);\r
142  \r
143 -    if (run_hooks) {\r
144 +    if (!no_hooks) {\r
145         ret = notmuch_run_hook (db_path, "pre-new");\r
146         if (ret)\r
147             return ret;\r
148 @@ -1045,7 +1045,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])\r
149  \r
150      notmuch_database_destroy (notmuch);\r
151  \r
152 -    if (run_hooks && !ret && !interrupted)\r
153 +    if (!no_hooks && !ret && !interrupted)\r
154         ret = notmuch_run_hook (db_path, "post-new");\r
155  \r
156      return ret || interrupted;\r
157 -- \r
158 1.7.10.4\r
159 \r