[PATCH v2 06/14] cli/reply: make references header creation easier to follow
[notmuch-archives.git] / 96 / 2b6d345d065e046d8020704819cb03f1bd5be3
1 Return-Path: <amdragon@mit.edu>\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 7B587431FCF\r
6         for <notmuch@notmuchmail.org>; Thu, 24 May 2012 12:32:10 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id C+OCvemrQEsZ for <notmuch@notmuchmail.org>;\r
16         Thu, 24 May 2012 12:32:09 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU\r
18         [18.7.68.34])\r
19         by olra.theworths.org (Postfix) with ESMTP id 29750431E62\r
20         for <notmuch@notmuchmail.org>; Thu, 24 May 2012 12:32:09 -0700 (PDT)\r
21 X-AuditID: 12074422-b7fd66d0000008f9-07-4fbe8cb78529\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
23         by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id ED.9B.02297.7BC8EBF4; Thu, 24 May 2012 15:32:07 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q4OJW7I7025151; \r
27         Thu, 24 May 2012 15:32:07 -0400\r
28 Received: from drake.mit.edu (26-4-163.dynamic.csail.mit.edu [18.26.4.163])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q4OJW5cB014461\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Thu, 24 May 2012 15:32:06 -0400 (EDT)\r
34 Received: from amthrax by drake.mit.edu with local (Exim 4.77)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1SXdlT-0003Rc-U3; Thu, 24 May 2012 15:32:03 -0400\r
37 From: Austin Clements <amdragon@MIT.EDU>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH v3 3/4] new: Merge error checks from add_files and\r
40         add_files_recursive\r
41 Date: Thu, 24 May 2012 15:32:01 -0400\r
42 Message-Id: <1337887922-13163-4-git-send-email-amdragon@mit.edu>\r
43 X-Mailer: git-send-email 1.7.10\r
44 In-Reply-To: <1337887922-13163-1-git-send-email-amdragon@mit.edu>\r
45 References: <1336429240-1114-1-git-send-email-amdragon@mit.edu>\r
46         <1337887922-13163-1-git-send-email-amdragon@mit.edu>\r
47 X-Brightmail-Tracker:\r
48  H4sIAAAAAAAAA+NgFtrEIsWRmVeSWpSXmKPExsUixCmqrbu9Z5+/QetLC4vrN2cyOzB6PFt1\r
49         izmAMYrLJiU1J7MstUjfLoEr49EU64LD/BVzL7WwNDBO5Oli5OSQEDCRWPXiNSuELSZx4d56\r
50         ti5GLg4hgX2MEsd+z2CGcDYwSryccQXKOc4ksbP1GAuEM4tRovtnFzNIP5uAhsS2/csZQWwR\r
51         AWmJnXdnA83l4GAWUJP406UCEhYWCJPYPn0rC4jNIqAq0bH8MZjNK+Ag8ebZREaIM+Qlnt7v\r
52         YwOxOQUcJS48mcwEYgsJlEkcf7yLaQIj/wJGhlWMsim5Vbq5iZk5xanJusXJiXl5qUW6pnq5\r
53         mSV6qSmlmxhBQcPuorSD8edBpUOMAhyMSjy8LNH7/IVYE8uKK3MPMUpyMCmJ8vJ1A4X4kvJT\r
54         KjMSizPii0pzUosPMUpwMCuJ8ApGAuV4UxIrq1KL8mFS0hwsSuK8azR3+wsJpCeWpGanphak\r
55         FsFkZTg4lCR4WYDRISRYlJqeWpGWmVOCkGbi4AQZzgM0fB/IYt7igsTc4sx0iPwpRkUpcd6L\r
56         IAkBkERGaR5cLyyqXzGKA70izPsXpIoHmBDgul8BDWYCGrzl8V6QwSWJCCmpBsaShuiJaxrb\r
57         nvvvrVndqLRNzlzOdFnIpvTpzF3JVz/0bX1230GstPXnVCYjRmt3xkb/rNuZP77dyO7Wrp15\r
58         XvO7wppzk37yF/6p+qho9fnwe+71wuceTF1y5NEmdTXhFTWKLwO+r+i5qhljzx+XEliTf8H/\r
59         5PJkUfbDzFzMs1XDonifXJJ1D1JiKc5INNRiLipOBAAyaYvZxQIAAA==\r
60 X-BeenThere: notmuch@notmuchmail.org\r
61 X-Mailman-Version: 2.1.13\r
62 Precedence: list\r
63 List-Id: "Use and development of the notmuch mail system."\r
64         <notmuch.notmuchmail.org>\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
68 List-Post: <mailto:notmuch@notmuchmail.org>\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
72 X-List-Received-Date: Thu, 24 May 2012 19:32:10 -0000\r
73 \r
74 Before XXX, add_files_recursive could have been called on a symlink to\r
75 a non-directory.  Hence, calling it on a non-directory was not an\r
76 error, so a separate function, add_files, existed to fail loudly in\r
77 situations where the path had to be a directory.\r
78 \r
79 With the new stat-ing logic, add_files_recursive is always called on\r
80 directories, so the separation of this logic is no longer necessary.\r
81 Hence, this patch moves the strict error checking previously done by\r
82 add_files into add_files_recursive.\r
83 ---\r
84  notmuch-new.c |   27 +++++----------------------\r
85  1 file changed, 5 insertions(+), 22 deletions(-)\r
86 \r
87 diff --git a/notmuch-new.c b/notmuch-new.c\r
88 index c64f1a7..2b05605 100644\r
89 --- a/notmuch-new.c\r
90 +++ b/notmuch-new.c\r
91 @@ -308,11 +308,10 @@ add_files_recursive (notmuch_database_t *notmuch,\r
92      }\r
93      stat_time = time (NULL);\r
94  \r
95 -    /* This is not an error since we may have recursed based on a\r
96 -     * symlink to a regular file, not a directory, and we don't know\r
97 -     * that until this stat. */\r
98 -    if (! S_ISDIR (st.st_mode))\r
99 -       return NOTMUCH_STATUS_SUCCESS;\r
100 +    if (! S_ISDIR (st.st_mode)) {\r
101 +       fprintf (stderr, "Error: %s is not a directory.\n", path);\r
102 +       return NOTMUCH_STATUS_FILE_ERROR;\r
103 +    }\r
104  \r
105      fs_mtime = st.st_mtime;\r
106  \r
107 @@ -655,23 +654,7 @@ add_files (notmuch_database_t *notmuch,\r
108            const char *path,\r
109            add_files_state_t *state)\r
110  {\r
111 -    notmuch_status_t status;\r
112 -    struct stat st;\r
113 -\r
114 -    if (stat (path, &st)) {\r
115 -       fprintf (stderr, "Error reading directory %s: %s\n",\r
116 -                path, strerror (errno));\r
117 -       return NOTMUCH_STATUS_FILE_ERROR;\r
118 -    }\r
119 -\r
120 -    if (! S_ISDIR (st.st_mode)) {\r
121 -       fprintf (stderr, "Error: %s is not a directory.\n", path);\r
122 -       return NOTMUCH_STATUS_FILE_ERROR;\r
123 -    }\r
124 -\r
125 -    status = add_files_recursive (notmuch, path, state);\r
126 -\r
127 -    return status;\r
128 +    return add_files_recursive (notmuch, path, state);\r
129  }\r
130  \r
131  /* XXX: This should be merged with the add_files function since it\r
132 -- \r
133 1.7.10\r
134 \r