Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / f7 / 594d5168d25e91601421ee598cfe8b38cfd91e
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 CC4B1431FD5\r
6         for <notmuch@notmuchmail.org>; Sun,  7 Apr 2013 10:15:21 -0700 (PDT)\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 LM63a-k5T2xq for <notmuch@notmuchmail.org>;\r
17         Sun,  7 Apr 2013 10:15:20 -0700 (PDT)\r
18 Received: from mail-la0-f41.google.com (mail-la0-f41.google.com\r
19         [209.85.215.41]) (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 30E34431FCB\r
22         for <notmuch@notmuchmail.org>; Sun,  7 Apr 2013 10:15:20 -0700 (PDT)\r
23 Received: by mail-la0-f41.google.com with SMTP id eg20so665140lab.28\r
24         for <notmuch@notmuchmail.org>; Sun, 07 Apr 2013 10:15:17 -0700 (PDT)\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
26         d=google.com; s=20120113;\r
27         h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to\r
28         :references:in-reply-to:references:x-gm-message-state;\r
29         bh=7DB9c1D52BfgAp/3fsKGTtVlx0hpWx7idOBaEE9dhRQ=;\r
30         b=DcXnJmTL1nIFQ3+Tr5myVBxKMgLqhOBTq5GMOBilCBBOwxDLaHnqGKQOO0/Pjzcg+I\r
31         dfeQONhmBrBGUCdrq2BnfohQzUNWcA6CmZzO6Mm34VZeabZ55gJa60HO+Bbje86aUbyx\r
32         FgDbgyPbgRlF7WAw0qCpeQlDzX6uv1T8LIM36smRhe/y7Whyimh0iIPsTM6v96fHF7bT\r
33         8RcQUkGMTyItoirOjaqLiaQcK8Xzg8FlGEoQyQY2a+zsPgGQTSxicyiYb+LZqu9pYICT\r
34         O0SEkG6rOODDQcRbYQzd+BnYLOBb9WCCBYDirLBWtL1tKrP2ImpZmJYfw7GhZNTLs9O+\r
35         QZfg==\r
36 X-Received: by 10.112.154.170 with SMTP id vp10mr5937697lbb.10.1365354917336; \r
37         Sun, 07 Apr 2013 10:15:17 -0700 (PDT)\r
38 Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi.\r
39         [80.223.81.27])\r
40         by mx.google.com with ESMTPS id c7sm9250623lbe.6.2013.04.07.10.15.15\r
41         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
42         Sun, 07 Apr 2013 10:15:16 -0700 (PDT)\r
43 From: Jani Nikula <jani@nikula.org>\r
44 To: notmuch@notmuchmail.org\r
45 Subject: [PATCH 2/3] cli: config: do not overwrite symlinks when saving config\r
46         file\r
47 Date: Sun,  7 Apr 2013 20:15:03 +0300\r
48 Message-Id:\r
49  <5502b2718a124b074b14c1835320e8b825a79045.1365354320.git.jani@nikula.org>\r
50 X-Mailer: git-send-email 1.7.10.4\r
51 In-Reply-To: <cover.1365354320.git.jani@nikula.org>\r
52 References: <cover.1365354320.git.jani@nikula.org>\r
53 In-Reply-To: <cover.1365354320.git.jani@nikula.org>\r
54 References: <cover.1365354320.git.jani@nikula.org>\r
55 X-Gm-Message-State:\r
56  ALoCoQmyo412e5C/Ju0/PFulYZ6RYWpN/rYa4fL7F9BIa3WAPey42sIADzWIRe0LsDpai4m/5asT\r
57 Cc: Tomi Ollila <tomi.ollila@iki.fi>\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.13\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62         <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Sun, 07 Apr 2013 17:15:22 -0000\r
71 \r
72 Use realpath to canonicalize the config path before writing.\r
73 \r
74 Previously 'notmuch setup' and 'notmuch config set' overwrote the\r
75 config file even if it was a symbolic link.\r
76 ---\r
77  notmuch-config.c |   24 ++++++++++++++++++++----\r
78  test/config      |    1 -\r
79  2 files changed, 20 insertions(+), 5 deletions(-)\r
80 \r
81 diff --git a/notmuch-config.c b/notmuch-config.c\r
82 index 66a1cdf..d9c2eb3 100644\r
83 --- a/notmuch-config.c\r
84 +++ b/notmuch-config.c\r
85 @@ -444,7 +444,7 @@ int\r
86  notmuch_config_save (notmuch_config_t *config)\r
87  {\r
88      size_t length;\r
89 -    char *data;\r
90 +    char *data, *filename;\r
91      GError *error = NULL;\r
92  \r
93      data = g_key_file_to_data (config->key_file, &length, NULL);\r
94 @@ -453,14 +453,30 @@ notmuch_config_save (notmuch_config_t *config)\r
95         return 1;\r
96      }\r
97  \r
98 -    if (! g_file_set_contents (config->filename, data, length, &error)) {\r
99 -       fprintf (stderr, "Error saving configuration to %s: %s\n",\r
100 -                config->filename, error->message);\r
101 +    /* Try not to overwrite symlinks. */\r
102 +    filename = realpath (config->filename, NULL);\r
103 +    if (! filename) {\r
104 +       fprintf (stderr, "Error canonicalizing %s: %s\n", config->filename,\r
105 +                strerror (errno));\r
106 +       g_free (data);\r
107 +       return 1;\r
108 +    }\r
109 +\r
110 +    if (! g_file_set_contents (filename, data, length, &error)) {\r
111 +       if (strcmp (filename, config->filename) != 0) {\r
112 +           fprintf (stderr, "Error saving configuration to %s (-> %s): %s\n",\r
113 +                    config->filename, filename, error->message);\r
114 +       } else {\r
115 +           fprintf (stderr, "Error saving configuration to %s: %s\n",\r
116 +                    filename, error->message);\r
117 +       }\r
118         g_error_free (error);\r
119 +       free (filename);\r
120         g_free (data);\r
121         return 1;\r
122      }\r
123  \r
124 +    free (filename);\r
125      g_free (data);\r
126      return 0;\r
127  }\r
128 diff --git a/test/config b/test/config\r
129 index 344eced..ca4cf33 100755\r
130 --- a/test/config\r
131 +++ b/test/config\r
132 @@ -78,7 +78,6 @@ test_expect_equal "$(notmuch --config=alt-config-link config get user.name)" \\r
133      "Link Name"\r
134  \r
135  test_begin_subtest "Writing config file through symlink follows symlink"\r
136 -test_subtest_known_broken\r
137  test_expect_equal "$(readlink alt-config-link)" "alt-config"\r
138  \r
139  test_done\r
140 -- \r
141 1.7.10.4\r
142 \r