mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-12-11 20:14:51 +01:00
lib/config: use g_key_file_get_string to read config values
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.
This commit is contained in:
parent
482bd3a46d
commit
18cdd21b8b
3 changed files with 3 additions and 5 deletions
|
@ -435,7 +435,7 @@ _notmuch_config_load_from_file (notmuch_database_t *notmuch,
|
||||||
for (gchar **keys_p = keys; *keys_p; keys_p++) {
|
for (gchar **keys_p = keys; *keys_p; keys_p++) {
|
||||||
char *absolute_key = talloc_asprintf (notmuch, "%s.%s", *grp, *keys_p);
|
char *absolute_key = talloc_asprintf (notmuch, "%s.%s", *grp, *keys_p);
|
||||||
char *normalized_val;
|
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) {
|
if (! val) {
|
||||||
status = NOTMUCH_STATUS_FILE_ERROR;
|
status = NOTMUCH_STATUS_FILE_ERROR;
|
||||||
goto DONE;
|
goto DONE;
|
||||||
|
|
|
@ -198,7 +198,7 @@ _choose_database_path (void *ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! *database_path && key_file) {
|
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) {
|
||||||
if (path[0] == '/')
|
if (path[0] == '/')
|
||||||
*database_path = talloc_strdup (ctx, path);
|
*database_path = talloc_strdup (ctx, path);
|
||||||
|
@ -642,7 +642,7 @@ notmuch_database_create_with_config (const char *database_path,
|
||||||
|
|
||||||
if (key_file && ! split) {
|
if (key_file && ! split) {
|
||||||
char *mail_root = notmuch_canonicalize_file_name (
|
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);
|
char *db_path = notmuch_canonicalize_file_name (database_path);
|
||||||
|
|
||||||
split = (mail_root && (0 != strcmp (mail_root, db_path)));
|
split = (mail_root && (0 != strcmp (mail_root, db_path)));
|
||||||
|
|
|
@ -85,13 +85,11 @@ output=$(notmuch config get foo.bar)
|
||||||
test_expect_equal "${output}" "thing other"
|
test_expect_equal "${output}" "thing other"
|
||||||
|
|
||||||
test_begin_subtest "Round trip config item with embedded backslash"
|
test_begin_subtest "Round trip config item with embedded backslash"
|
||||||
test_subtest_known_broken
|
|
||||||
notmuch config set foo.bar 'thing\other'
|
notmuch config set foo.bar 'thing\other'
|
||||||
output=$(notmuch config get foo.bar)
|
output=$(notmuch config get foo.bar)
|
||||||
test_expect_equal "${output}" "thing\other"
|
test_expect_equal "${output}" "thing\other"
|
||||||
|
|
||||||
test_begin_subtest "Round trip config item with embedded NL/CR"
|
test_begin_subtest "Round trip config item with embedded NL/CR"
|
||||||
test_subtest_known_broken
|
|
||||||
notmuch config set foo.bar 'thing
|
notmuch config set foo.bar 'thing
|
||||||
other'
|
other'
|
||||||
output=$(notmuch config get foo.bar)
|
output=$(notmuch config get foo.bar)
|
||||||
|
|
Loading…
Reference in a new issue