]> git.notmuchmail.org Git - notmuch/commitdiff
lib/config: use g_key_file_get_string to read config values
authorDavid Bremner <david@tethera.net>
Thu, 30 Sep 2021 18:59:54 +0000 (15:59 -0300)
committerDavid Bremner <david@tethera.net>
Sat, 4 Dec 2021 16:17:09 +0000 (12:17 -0400)
Unlike the previous g_key_file_get_value, this version processes
escape codes for whitespace and \. The remaining two broken tests from
the last commit are because "notmuch config get" treats every value as
a list, and thus the previously introduces stripping of leading
whitespace applies.

lib/config.cc
lib/open.cc
test/T030-config.sh

index e502858d623db091628e4945d7736c0db2d5b2cd..7a2882dea2360a87ba3bc511c0cdd3c829de20aa 100644 (file)
@@ -435,7 +435,7 @@ _notmuch_config_load_from_file (notmuch_database_t *notmuch,
        for (gchar **keys_p = keys; *keys_p; keys_p++) {
            char *absolute_key = talloc_asprintf (notmuch, "%s.%s", *grp,  *keys_p);
            char *normalized_val;
-           val = g_key_file_get_value (file, *grp, *keys_p, NULL);
+           val = g_key_file_get_string (file, *grp, *keys_p, NULL);
            if (! val) {
                status = NOTMUCH_STATUS_FILE_ERROR;
                goto DONE;
index c2cb281865e7beccbe9a3046c8f911855820a436..a91d22efe6ecbf5e133dc1daded781229f9bf0a9 100644 (file)
@@ -198,7 +198,7 @@ _choose_database_path (void *ctx,
     }
 
     if (! *database_path && key_file) {
-       char *path = g_key_file_get_value (key_file, "database", "path", NULL);
+       char *path = g_key_file_get_string (key_file, "database", "path", NULL);
        if (path) {
            if (path[0] == '/')
                *database_path = talloc_strdup (ctx, path);
@@ -642,7 +642,7 @@ notmuch_database_create_with_config (const char *database_path,
 
     if (key_file && ! split) {
        char *mail_root = notmuch_canonicalize_file_name (
-           g_key_file_get_value (key_file, "database", "mail_root", NULL));
+           g_key_file_get_string (key_file, "database", "mail_root", NULL));
        char *db_path = notmuch_canonicalize_file_name (database_path);
 
        split = (mail_root && (0 != strcmp (mail_root, db_path)));
index 1fdde9fe4e50f24416c324079c4631c772707d73..43bbce31057d4fc108621c505057618d5b0d9990 100755 (executable)
@@ -85,13 +85,11 @@ output=$(notmuch config get foo.bar)
 test_expect_equal "${output}" "thing   other"
 
 test_begin_subtest "Round trip config item with embedded backslash"
-test_subtest_known_broken
 notmuch config set foo.bar 'thing\other'
 output=$(notmuch config get foo.bar)
 test_expect_equal "${output}" "thing\other"
 
 test_begin_subtest "Round trip config item with embedded NL/CR"
-test_subtest_known_broken
 notmuch config set foo.bar 'thing
 \rother'
 output=$(notmuch config get foo.bar)