aboutsummaryrefslogtreecommitdiff
path: root/notmuch-config.c
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2023-08-20 12:10:56 -0300
committerDavid Bremner <david@tethera.net>2023-08-21 19:30:54 -0300
commitdf45194d5ffc110d69811eecd50f744c2b8c3805 (patch)
tree0c79306dae77e47c1be401984a6b6047613dd896 /notmuch-config.c
parent1719b9e568fb944ffb91126b164a18a30a415d0a (diff)
CLI/config: simulate top level comments when creating config
According to discussion on https://gitlab.gnome.org/GNOME/glib/-/issues/3078 it looks like upstream will stop supporting top of file comments. It is questionable whether we really need this feature, but for now update notmuch-config to simulate it.
Diffstat (limited to 'notmuch-config.c')
-rw-r--r--notmuch-config.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/notmuch-config.c b/notmuch-config.c
index e9456d79..8123e438 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -278,18 +278,24 @@ notmuch_conffile_open (notmuch_database_t *notmuch,
return NULL;
}
- if (config->is_new)
- g_key_file_set_comment (config->key_file, NULL, NULL,
- toplevel_config_comment, NULL);
-
for (size_t i = 0; i < ARRAY_SIZE (group_comment_table); i++) {
const char *name = group_comment_table[i].group_name;
if (! g_key_file_has_group (config->key_file, name)) {
/* Force group to exist before adding comment */
g_key_file_set_value (config->key_file, name, "dummy_key", "dummy_val");
g_key_file_remove_key (config->key_file, name, "dummy_key", NULL);
- g_key_file_set_comment (config->key_file, name, NULL,
- group_comment_table[i].comment, NULL);
+ if (config->is_new && (i == 0) ) {
+ const char *comment;
+
+ comment = talloc_asprintf (config, "%s\n%s",
+ toplevel_config_comment,
+ group_comment_table[i].comment);
+ g_key_file_set_comment (config->key_file, name, NULL, comment,
+ NULL);
+ } else {
+ g_key_file_set_comment (config->key_file, name, NULL,
+ group_comment_table[i].comment, NULL);
+ }
}
}
return config;