mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 18:38:08 +01:00
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.
This commit is contained in:
parent
1719b9e568
commit
df45194d5f
1 changed files with 12 additions and 6 deletions
|
@ -278,20 +278,26 @@ notmuch_conffile_open (notmuch_database_t *notmuch,
|
||||||
return NULL;
|
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++) {
|
for (size_t i = 0; i < ARRAY_SIZE (group_comment_table); i++) {
|
||||||
const char *name = group_comment_table[i].group_name;
|
const char *name = group_comment_table[i].group_name;
|
||||||
if (! g_key_file_has_group (config->key_file, name)) {
|
if (! g_key_file_has_group (config->key_file, name)) {
|
||||||
/* Force group to exist before adding comment */
|
/* Force group to exist before adding comment */
|
||||||
g_key_file_set_value (config->key_file, name, "dummy_key", "dummy_val");
|
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_remove_key (config->key_file, name, "dummy_key", 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,
|
g_key_file_set_comment (config->key_file, name, NULL,
|
||||||
group_comment_table[i].comment, NULL);
|
group_comment_table[i].comment, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue