From: David Edmondson <dme@dme.org>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Subject: Re: [PATCH v1 2/2] notmuch: Database paths without a leading / are relative to $HOME
Date: Sat, 08 Sep 2018 10:22:53 +0100 [thread overview]
Message-ID: <cunworwmjgy.fsf@constant-mown.hh.sledj.net> (raw)
In-Reply-To: <87o9d8j1bx.fsf@tethera.net>
On Friday, 2018-09-07 at 21:10:42 -03, David Bremner wrote:
> David Edmondson <dme@dme.org> writes:
>
>> If the database path specified in the configuration file does *not*
>> start with a /, presume that it is relative to $HOME and modify the
>> path used to open the database accordingly.
>> ---
>> notmuch-config.c | 14 +++++++++++++-
>> 1 file changed, 13 insertions(+), 1 deletion(-)
>>
>> diff --git a/notmuch-config.c b/notmuch-config.c
>> index e1b16609..bf77cc9d 100644
>> --- a/notmuch-config.c
>> +++ b/notmuch-config.c
>> @@ -660,7 +660,19 @@ _config_set_list (notmuch_config_t *config,
>> const char *
>> notmuch_config_get_database_path (notmuch_config_t *config)
>> {
>> - return _config_get (config, &config->database_path, "database", "path");
>> + char *db_path = (char *)_config_get (config, &config->database_path, "database", "path");
>> +
>> + if (db_path && *db_path != '/') {
>> + /* If the path in the configuration file begins with any
>> + * character other than /, presume that it is relative to
>> + * $HOME and update as appropriate.
>> + */
>> + char *abs_path = talloc_asprintf (config, "%s/%s", getenv ("HOME"), db_path);
>> + talloc_free (db_path);
>> + db_path = config->database_path = abs_path;
>> + }
>
> In the unlikely event that HOME is not set, it would be nicer to print a
> message to that effect, rather than
I did think about that, but decided to follow existing practice in
notmuch, which doesn't check:
config->filename = talloc_asprintf (config, "%s/.notmuch-config",
getenv ("HOME"));
...and...
path = talloc_asprintf (config, "%s/mail",
getenv ("HOME"));
> configuration file (null)/.notmuch-config not found.
> Try running 'notmuch setup' to create a configuration.
dme.
--
It's funny, I spent my whole life wanting to be talked about.
next prev parent reply other threads:[~2018-09-08 9:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-25 11:57 [PATCH v1 0/2] Interpret a directory path without a leading slash as relative to $HOME David Edmondson
2018-08-25 11:57 ` [PATCH v1 1/2] test: Absolute and relative directory paths David Edmondson
2018-09-08 0:05 ` David Bremner
2018-09-08 9:22 ` David Edmondson
2018-09-08 10:27 ` David Bremner
2018-08-25 11:57 ` [PATCH v1 2/2] notmuch: Database paths without a leading / are relative to $HOME David Edmondson
2018-09-08 0:10 ` David Bremner
2018-09-08 9:22 ` David Edmondson [this message]
2018-09-08 10:28 ` David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cunworwmjgy.fsf@constant-mown.hh.sledj.net \
--to=dme@dme.org \
--cc=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).