The function _notmuch_config_load_from_file is only called in two
places in open.cc. Update internal API to match the idiom in open.cc.
Adding a newline is needed for consistency with other status strings.
Based in part on a patch [1] from Eric Blake.
[1]: id:
20230906153402.101471-1-eblake@redhat.com
notmuch_status_t
_notmuch_config_load_from_file (notmuch_database_t *notmuch,
notmuch_status_t
_notmuch_config_load_from_file (notmuch_database_t *notmuch,
+ GKeyFile *file,
+ char **status_string)
{
notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
gchar **groups = NULL, **keys, *val;
{
notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
gchar **groups = NULL, **keys, *val;
for (gchar **keys_p = keys; *keys_p; keys_p++) {
char *absolute_key = talloc_asprintf (notmuch, "%s.%s", *grp, *keys_p);
char *normalized_val;
for (gchar **keys_p = keys; *keys_p; keys_p++) {
char *absolute_key = talloc_asprintf (notmuch, "%s.%s", *grp, *keys_p);
char *normalized_val;
/* If we opened from a given path, do not overwrite it */
if (strcmp (absolute_key, "database.path") == 0 &&
/* If we opened from a given path, do not overwrite it */
if (strcmp (absolute_key, "database.path") == 0 &&
notmuch->xapian_db)
continue;
notmuch->xapian_db)
continue;
- val = g_key_file_get_string (file, *grp, *keys_p, NULL);
+ val = g_key_file_get_string (file, *grp, *keys_p, &gerr);
+ if (gerr) {
+ if (status_string)
+ IGNORE_RESULT (asprintf (status_string,
+ "GLib: %s\n",
+ gerr->message));
+ g_error_free (gerr);
+ }
if (! val) {
status = NOTMUCH_STATUS_FILE_ERROR;
goto DONE;
if (! val) {
status = NOTMUCH_STATUS_FILE_ERROR;
goto DONE;
_notmuch_config_load_from_database (notmuch_database_t *db);
notmuch_status_t
_notmuch_config_load_from_database (notmuch_database_t *db);
notmuch_status_t
-_notmuch_config_load_from_file (notmuch_database_t *db, GKeyFile *file);
+_notmuch_config_load_from_file (notmuch_database_t *db, GKeyFile *file, char **status_string);
notmuch_status_t
_notmuch_config_load_defaults (notmuch_database_t *db);
notmuch_status_t
_notmuch_config_load_defaults (notmuch_database_t *db);
- status = _notmuch_config_load_from_file (notmuch, key_file);
+ status = _notmuch_config_load_from_file (notmuch, key_file, &message);
- status = _notmuch_config_load_from_file (notmuch, key_file);
+ status = _notmuch_config_load_from_file (notmuch, key_file, &message);
NULL,
¬much,
&status_string);
NULL,
¬much,
&status_string);
+ if (status_string) {
+ fputs (status_string, stderr);
+ free (status_string);
+ status_string = NULL;
+ }
+
switch (status) {
case NOTMUCH_STATUS_NO_CONFIG:
if (! (command->mode & NOTMUCH_COMMAND_CONFIG_CREATE)) {
switch (status) {
case NOTMUCH_STATUS_NO_CONFIG:
if (! (command->mode & NOTMUCH_COMMAND_CONFIG_CREATE)) {
test_expect_code 1 "notmuch --config=./bad-config config list"
test_begin_subtest "Specific error message about bad utf8"
test_expect_code 1 "notmuch --config=./bad-config config list"
test_begin_subtest "Specific error message about bad utf8"
-test_subtest_known_broken
notmuch --config=./bad-config config list 2>ERRORS
cat <<EOF > EXPECTED
GLib: Key file contains key “q3” with value “from:�” which is not UTF-8
notmuch --config=./bad-config config list 2>ERRORS
cat <<EOF > EXPECTED
GLib: Key file contains key “q3” with value “from:�” which is not UTF-8