unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Adapt to breaking changes in glib .ini file handling
@ 2023-08-20 15:45 David Bremner
  2023-08-20 15:45 ` [PATCH 1/2] CLI/config: simulate top level comments when creating config David Bremner
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: David Bremner @ 2023-08-20 15:45 UTC (permalink / raw)
  To: notmuch

Glib upstream recently (2.77.1) decided to clean up several aspects of
comments in .ini files. Unfortunately these changes break the notmuch
test suite. This series seeks to adapt to the changes in question,
while being backward compatible to older versions of glib.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] CLI/config: simulate top level comments when creating config
  2023-08-20 15:45 Adapt to breaking changes in glib .ini file handling David Bremner
@ 2023-08-20 15:45 ` David Bremner
  2023-08-20 15:45 ` [PATCH 2/2] test/setup: ignore blank lines in generated config David Bremner
  2023-08-24 10:18 ` Adapt to breaking changes in glib .ini file handling David Bremner
  2 siblings, 0 replies; 4+ messages in thread
From: David Bremner @ 2023-08-20 15:45 UTC (permalink / raw)
  To: notmuch

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.
---
 notmuch-config.c | 18 ++++++++++++------
 1 file 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;
-- 
2.40.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] test/setup: ignore blank lines in generated config
  2023-08-20 15:45 Adapt to breaking changes in glib .ini file handling David Bremner
  2023-08-20 15:45 ` [PATCH 1/2] CLI/config: simulate top level comments when creating config David Bremner
@ 2023-08-20 15:45 ` David Bremner
  2023-08-24 10:18 ` Adapt to breaking changes in glib .ini file handling David Bremner
  2 siblings, 0 replies; 4+ messages in thread
From: David Bremner @ 2023-08-20 15:45 UTC (permalink / raw)
  To: notmuch

The presense of the blank lines between sections depends on the
version of glib. Strip them before comparison.
---
 test/T040-setup.sh                              | 3 ++-
 test/setup.expected-output/config-with-comments | 5 -----
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/test/T040-setup.sh b/test/T040-setup.sh
index 10b29ec3..39846d34 100755
--- a/test/T040-setup.sh
+++ b/test/T040-setup.sh
@@ -21,7 +21,8 @@ baz
 EOF
 
 expected_dir=$NOTMUCH_SRCDIR/test/setup.expected-output
-test_expect_equal_file ${expected_dir}/config-with-comments new-notmuch-config
+sed '/^$/d' < new-notmuch-config > filtered-config
+test_expect_equal_file ${expected_dir}/config-with-comments filtered-config
 
 test_begin_subtest "setup consistent with config-set for single items"
 # note this relies on the config state from the previous test.
diff --git a/test/setup.expected-output/config-with-comments b/test/setup.expected-output/config-with-comments
index d8397714..d925acea 100644
--- a/test/setup.expected-output/config-with-comments
+++ b/test/setup.expected-output/config-with-comments
@@ -1,7 +1,6 @@
 # .notmuch-config - Configuration file for the notmuch mail system
 #
 # For more information about notmuch, see https://notmuchmail.org
-
 # Database configuration
 #
 # The only value supported here is 'path' which should be the top-level
@@ -12,7 +11,6 @@
 #
 [database]
 path=/path/to/maildir
-
 # User configuration
 #
 # Here is where you can let notmuch know how you would like to be
@@ -32,7 +30,6 @@ path=/path/to/maildir
 name=Test Suite
 primary_email=test.suite@example.com
 other_email=another.suite@example.com
-
 # Configuration for "notmuch new"
 #
 # The following options are supported here:
@@ -49,7 +46,6 @@ other_email=another.suite@example.com
 #
 [new]
 tags=foo;bar;
-
 # Search configuration
 #
 # The following option is supported here:
@@ -61,7 +57,6 @@ tags=foo;bar;
 #
 [search]
 exclude_tags=baz
-
 # Maildir compatibility configuration
 #
 # The following option is supported here:
-- 
2.40.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: Adapt to breaking changes in glib .ini file handling
  2023-08-20 15:45 Adapt to breaking changes in glib .ini file handling David Bremner
  2023-08-20 15:45 ` [PATCH 1/2] CLI/config: simulate top level comments when creating config David Bremner
  2023-08-20 15:45 ` [PATCH 2/2] test/setup: ignore blank lines in generated config David Bremner
@ 2023-08-24 10:18 ` David Bremner
  2 siblings, 0 replies; 4+ messages in thread
From: David Bremner @ 2023-08-24 10:18 UTC (permalink / raw)
  To: notmuch

David Bremner <david@tethera.net> writes:

> Glib upstream recently (2.77.1) decided to clean up several aspects of
> comments in .ini files. Unfortunately these changes break the notmuch
> test suite. This series seeks to adapt to the changes in question,
> while being backward compatible to older versions of glib.

Series applied to master.

d

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-24 10:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-20 15:45 Adapt to breaking changes in glib .ini file handling David Bremner
2023-08-20 15:45 ` [PATCH 1/2] CLI/config: simulate top level comments when creating config David Bremner
2023-08-20 15:45 ` [PATCH 2/2] test/setup: ignore blank lines in generated config David Bremner
2023-08-24 10:18 ` Adapt to breaking changes in glib .ini file handling David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).