[PATCH] config: Expand ~ to $HOME
authorBijan Chokoufe Nejad <bijan@chokoufe.com>
Sun, 8 May 2016 15:49:34 +0000 (17:49 +0200)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:21:47 +0000 (16:21 -0700)
b1/0c8f4b27630b3187ea42ef3c4e3b1abe1c16cf [new file with mode: 0644]

diff --git a/b1/0c8f4b27630b3187ea42ef3c4e3b1abe1c16cf b/b1/0c8f4b27630b3187ea42ef3c4e3b1abe1c16cf
new file mode 100644 (file)
index 0000000..14180d9
--- /dev/null
@@ -0,0 +1,108 @@
+Return-Path: <bijan.chokoufe@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 8FF0B6DE00EB\r
+ for <notmuch@notmuchmail.org>; Sun,  8 May 2016 08:50:06 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.47\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.47 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1,\r
+ FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001,\r
+ HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_LOW=-0.7,\r
+ RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id IrETlqkOY2w4 for <notmuch@notmuchmail.org>;\r
+ Sun,  8 May 2016 08:49:57 -0700 (PDT)\r
+Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com\r
+ [74.125.82.66]) by arlo.cworth.org (Postfix) with ESMTPS id CAAA56DE0022 for\r
+ <notmuch@notmuchmail.org>; Sun,  8 May 2016 08:49:56 -0700 (PDT)\r
+Received: by mail-wm0-f66.google.com with SMTP id w143so16747169wmw.3\r
+ for <notmuch@notmuchmail.org>; Sun, 08 May 2016 08:49:56 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=sender:from:to:cc:subject:date:message-id;\r
+ bh=Ul8eytKlozsYZyVbm9I2bHygmkFi2wYK7vsUqwQW7Js=;\r
+ b=o9QU/3dq92/SR3DGHKBh/eDxZ/iiZ3qGVEEngbSVFBfc1t2TYAQDM1i74sKZKxluLl\r
+ rQA7jEvPcs6R4AVohwVpMGfpg+69tpySZHgkz4Vv2zTQN5blshfBNfY0jW8Z/YSCbOYK\r
+ ZEtVCjoZsOnnjkno1Y4um6IiepUVW/VCfxLX5aD81muAbSSLOgt4RykGBxL/DcqtdHZl\r
+ FFa+KGxU2OeT8z4E7AO3k9jkB3UjkA3cP8kuOuh67NS43ri/VRYuan8h9HvUJ4KQZmtJ\r
+ lJ2zIKUjwtNllK58TFRYzaB+YfdbXooE9n32N90CDVjFKP7oahxOHlRWRVwETl1enP/J\r
+ InHA==\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:sender:from:to:cc:subject:date:message-id;\r
+ bh=Ul8eytKlozsYZyVbm9I2bHygmkFi2wYK7vsUqwQW7Js=;\r
+ b=VX+kMVnnmXsLk3nXnu+m/4mnU0eqLi5colL4cnEdPi+/qxsKQkeDTnYEqcf3zBmYyU\r
+ VBLKnA+lHJGvZWlabKYtARoX9Z0wXs8iRe4c/PrhJYkTv79vUGw1kpuyJzgNdT47uEmM\r
+ 6lI6z7u2ZknsooBL6+LMVLmmEYLd06VHaJHKPQM6uUyLOA64rvMw8P5I4VPbLUXd6Ho8\r
+ OvKXMWImUXK4DyHoqTo90oZp7k3NYcWi+uxsTMq35xxc5oD+yHuXfRlKOl/mLrurjhJV\r
+ OFO+GJfaW+joTwT1H2t/yB7S5QxvyvWfxt7ovMOSTCObYJa5xF9jMUJgcXtyGLHLqWpN\r
+ XliA==\r
+X-Gm-Message-State:\r
+ AOPr4FWtjrBA7z5CZyLMt1iZfSWFEr7zTQambNnAzQoFGL9Blp4NMp2hpKJ0kGgeKfxlOA==\r
+X-Received: by 10.194.114.100 with SMTP id jf4mr28087233wjb.55.1462722595025; \r
+ Sun, 08 May 2016 08:49:55 -0700 (PDT)\r
+Received: from localhost.localdomain (ip5f5be327.dynamic.kabel-deutschland.de.\r
+ [95.91.227.39])\r
+ by smtp.gmail.com with ESMTPSA id lr9sm8040308wjb.39.2016.05.08.08.49.53\r
+ (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\r
+ Sun, 08 May 2016 08:49:54 -0700 (PDT)\r
+Sender: Bijan Chokoufe <bijan.chokoufe@gmail.com>\r
+From: Bijan Chokoufe Nejad <bijan@chokoufe.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] config: Expand ~ to $HOME\r
+Date: Sun,  8 May 2016 17:49:34 +0200\r
+Message-Id: <1462722574-4176-1-git-send-email-bijan@chokoufe.com>\r
+X-Mailer: git-send-email 1.9.1\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 08 May 2016 15:50:06 -0000\r
+\r
+Very useful in case you want to keep your .notmuch-config synchronized across\r
+machines where you have different user names.\r
+---\r
+Not sure this is completely plattform independent.\r
+I also don't know how to implement a unit test for this.\r
+---\r
+ notmuch-config.c | 11 ++++++++++-\r
+ 1 file changed, 10 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/notmuch-config.c b/notmuch-config.c\r
+index d252bb2..c9f26ef 100644\r
+--- a/notmuch-config.c\r
++++ b/notmuch-config.c\r
+@@ -605,7 +605,16 @@ _config_set_list (notmuch_config_t *config,\r
+ const char *\r
+ notmuch_config_get_database_path (notmuch_config_t *config)\r
+ {\r
+-    return _config_get (config, &config->database_path, "database", "path");\r
++    const char* path = _config_get (config, &config->database_path, "database", "path");\r
++    if (path != NULL && path[0] == '~') {\r
++        char *home_path = getenv("HOME");\r
++        char *shortened_path = malloc( sizeof(char) * ( strlen (path) - 1 ) );\r
++        strncpy(shortened_path, path + 2, strlen(path));\r
++        return talloc_asprintf (NULL, "%s/%s", home_path, shortened_path);\r
++    }\r
++    else {\r
++        return path;\r
++    }\r
+ }\r
\r
+ void\r
+-- \r
+1.9.1\r
+\r