unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH v2 1/2] notmuch: Database paths without a leading / are relative to $HOME
@ 2018-09-08 11:49 David Edmondson
  2018-09-08 11:49 ` [PATCH v2 2/2] test: Absolute and relative directory paths David Edmondson
  2018-09-08 14:28 ` [PATCH v2 1/2] notmuch: Database paths without a leading / are relative to $HOME Tomi Ollila
  0 siblings, 2 replies; 4+ messages in thread
From: David Edmondson @ 2018-09-08 11:49 UTC (permalink / raw
  To: notmuch

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;
+    }
+
+    return db_path;
 }
 
 void
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-09-08 23:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-08 11:49 [PATCH v2 1/2] notmuch: Database paths without a leading / are relative to $HOME David Edmondson
2018-09-08 11:49 ` [PATCH v2 2/2] test: Absolute and relative directory paths David Edmondson
2018-09-08 14:28 ` [PATCH v2 1/2] notmuch: Database paths without a leading / are relative to $HOME Tomi Ollila
2018-09-08 23:49   ` David Bremner

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).