[PATCH 05/22] CLI/show: complete conversion to new configuration framework.

2021-03-14 Thread David Bremner
In order to open the database in main() for this command, we may need
to re-open it in the (possibly less common) case where crypto options
require write access.
---
 notmuch-show.c   | 28 
 notmuch.c|  2 +-
 test/T035-read-config.sh |  2 --
 3 files changed, 9 insertions(+), 23 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index b6b53991..5fd1ce25 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1225,10 +1225,9 @@ static const notmuch_show_format_t *formatters[] = {
 };
 
 int
-notmuch_show_command (notmuch_config_t *config, unused(notmuch_database_t 
*notmuch),
+notmuch_show_command (unused (notmuch_config_t *config), notmuch_database_t 
*notmuch,
  int argc, char *argv[])
 {
-notmuch_database_t *notmuch;
 notmuch_query_t *query;
 char *query_string;
 int opt_index, ret;
@@ -1245,7 +1244,7 @@ notmuch_show_command (notmuch_config_t *config, 
unused(notmuch_database_t *notmu
 bool entire_thread_set = false;
 bool single_message;
 bool unthreaded = FALSE;
-char *status_string = NULL;
+notmuch_status_t status;
 
 notmuch_opt_desc_t options[] = {
{ .opt_keyword = , .name = "format", .keywords =
@@ -1336,26 +1335,15 @@ notmuch_show_command (notmuch_config_t *config, 
unused(notmuch_database_t *notmu
 "Warning: --include-html only implemented for format=text, 
format=json and format=sexp\n");
 }
 
-notmuch_database_mode_t mode = NOTMUCH_DATABASE_MODE_READ_ONLY;
-
-if (params.crypto.decrypt == NOTMUCH_DECRYPT_TRUE)
-   mode = NOTMUCH_DATABASE_MODE_READ_WRITE;
-if (notmuch_database_open_with_config (NULL,
-  mode,
-  _notmuch_config_get_path (config),
-  NULL,
-  ,
-  _string)) {
-   if (status_string) {
-   fputs (status_string, stderr);
-   free (status_string);
+if (params.crypto.decrypt == NOTMUCH_DECRYPT_TRUE) {
+   status = notmuch_database_reopen (notmuch, 
NOTMUCH_DATABASE_MODE_READ_WRITE);
+   if (status) {
+   fprintf (stderr, "Error reopening database for READ_WRITE: %s\n",
+ notmuch_status_to_string (status));
+   return EXIT_FAILURE;
}
-
-   return EXIT_FAILURE;
 }
 
-config = NULL;
-
 notmuch_exit_if_unmatched_db_uuid (notmuch);
 
 query_string = query_string_from_args (notmuch, argc - opt_index, argv + 
opt_index);
diff --git a/notmuch.c b/notmuch.c
index 5e56209b..f2bf9c24 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -156,7 +156,7 @@ static command_t commands[] = {
   "Search for messages matching the given search terms." },
 { "address", notmuch_address_command, NOTMUCH_COMMAND_DATABASE_EARLY,
   "Get addresses from messages matching the given search terms." },
-{ "show", notmuch_show_command, NOTMUCH_COMMAND_CONFIG_OPEN,
+{ "show", notmuch_show_command, NOTMUCH_COMMAND_DATABASE_EARLY,
   "Show all messages matching the search terms." },
 { "count", notmuch_count_command, NOTMUCH_COMMAND_DATABASE_EARLY,
   "Count messages matching the search terms." },
diff --git a/test/T035-read-config.sh b/test/T035-read-config.sh
index 205d1736..ac0f420b 100755
--- a/test/T035-read-config.sh
+++ b/test/T035-read-config.sh
@@ -378,7 +378,6 @@ restore_database
 test_expect_equal "$output" "OK"
 
 test_begin_subtest "show with alternate config (xdg)"
-test_subtest_known_broken
 backup_database
 notmuch tag -- +foobar17 '*'
 xdg_config
@@ -389,7 +388,6 @@ restore_config
 test_expect_equal "$output" "OK"
 
 test_begin_subtest "show with alternate config (xdg+profile)"
-test_subtest_known_broken
 backup_database
 notmuch tag -- +foobar17 '*'
 xdg_config foobar17
-- 
2.30.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 05/22] CLI/show: complete conversion to new configuration framework.

2021-03-07 Thread David Bremner
In order to open the database in main() for this command, we may need
to re-open it in the (possibly less common) case where crypto options
require it.
---
 notmuch-show.c   | 27 +++
 notmuch.c|  2 +-
 test/T035-read-config.sh |  2 --
 3 files changed, 8 insertions(+), 23 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 2c474682..ce8b9915 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1218,9 +1218,8 @@ static const notmuch_show_format_t *formatters[] = {
 };
 
 int
-notmuch_show_command (notmuch_config_t *config, unused(notmuch_database_t 
*notmuch), int argc, char *argv[])
+notmuch_show_command (unused (notmuch_config_t *config), notmuch_database_t 
*notmuch, int argc, char *argv[])
 {
-notmuch_database_t *notmuch;
 notmuch_query_t *query;
 char *query_string;
 int opt_index, ret;
@@ -1237,7 +1236,7 @@ notmuch_show_command (notmuch_config_t *config, 
unused(notmuch_database_t *notmu
 bool entire_thread_set = false;
 bool single_message;
 bool unthreaded = FALSE;
-char *status_string = NULL;
+notmuch_status_t status;
 
 notmuch_opt_desc_t options[] = {
{ .opt_keyword = , .name = "format", .keywords =
@@ -1327,26 +1326,14 @@ notmuch_show_command (notmuch_config_t *config, 
unused(notmuch_database_t *notmu
fprintf (stderr, "Warning: --include-html only implemented for 
format=text, format=json and format=sexp\n");
 }
 
-notmuch_database_mode_t mode = NOTMUCH_DATABASE_MODE_READ_ONLY;
-
-if (params.crypto.decrypt == NOTMUCH_DECRYPT_TRUE)
-   mode = NOTMUCH_DATABASE_MODE_READ_WRITE;
-if (notmuch_database_open_with_config (NULL,
-  mode,
-  _notmuch_config_get_path (config),
-  NULL,
-  ,
-  _string)) {
-   if (status_string) {
-   fputs (status_string, stderr);
-   free (status_string);
+if (params.crypto.decrypt == NOTMUCH_DECRYPT_TRUE) {
+   status = notmuch_database_reopen (notmuch, 
NOTMUCH_DATABASE_MODE_READ_WRITE);
+   if (status) {
+   fprintf (stderr, "Error reopening database for READ_WRITE: %s\n", 
notmuch_status_to_string (status));
+   return EXIT_FAILURE;
}
-
-   return EXIT_FAILURE;
 }
 
-config = NULL;
-
 notmuch_exit_if_unmatched_db_uuid (notmuch);
 
 query_string = query_string_from_args (notmuch, argc - opt_index, argv + 
opt_index);
diff --git a/notmuch.c b/notmuch.c
index 7360e0e6..71482e43 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -152,7 +152,7 @@ static command_t commands[] = {
   "Search for messages matching the given search terms." },
 { "address", notmuch_address_command, NOTMUCH_COMMAND_DATABASE_EARLY,
   "Get addresses from messages matching the given search terms." },
-{ "show", notmuch_show_command, NOTMUCH_COMMAND_CONFIG_OPEN,
+{ "show", notmuch_show_command, NOTMUCH_COMMAND_DATABASE_EARLY,
   "Show all messages matching the search terms." },
 { "count", notmuch_count_command, NOTMUCH_COMMAND_DATABASE_EARLY,
   "Count messages matching the search terms." },
diff --git a/test/T035-read-config.sh b/test/T035-read-config.sh
index 205d1736..ac0f420b 100755
--- a/test/T035-read-config.sh
+++ b/test/T035-read-config.sh
@@ -378,7 +378,6 @@ restore_database
 test_expect_equal "$output" "OK"
 
 test_begin_subtest "show with alternate config (xdg)"
-test_subtest_known_broken
 backup_database
 notmuch tag -- +foobar17 '*'
 xdg_config
@@ -389,7 +388,6 @@ restore_config
 test_expect_equal "$output" "OK"
 
 test_begin_subtest "show with alternate config (xdg+profile)"
-test_subtest_known_broken
 backup_database
 notmuch tag -- +foobar17 '*'
 xdg_config foobar17
-- 
2.30.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 05/22] CLI/show: complete conversion to new configuration framework.

2021-03-04 Thread David Bremner
In order to open the database in main() for this command, we may need
to re-open it in the (possibly less common) case where crypto options
require it.
---
 notmuch-show.c   | 26 +++---
 notmuch.c|  2 +-
 test/T035-read-config.sh |  2 --
 3 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index c3c42caa..4a26f8ce 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1215,9 +1215,8 @@ static const notmuch_show_format_t *formatters[] = {
 };
 
 int
-notmuch_show_command (notmuch_config_t *config, unused(notmuch_database_t 
*notmuch), int argc, char *argv[])
+notmuch_show_command (unused(notmuch_config_t *config), notmuch_database_t 
*notmuch, int argc, char *argv[])
 {
-notmuch_database_t *notmuch;
 notmuch_query_t *query;
 char *query_string;
 int opt_index, ret;
@@ -1234,7 +1233,7 @@ notmuch_show_command (notmuch_config_t *config, 
unused(notmuch_database_t *notmu
 bool entire_thread_set = false;
 bool single_message;
 bool unthreaded = FALSE;
-char *status_string = NULL;
+notmuch_status_t status;
 
 notmuch_opt_desc_t options[] = {
{ .opt_keyword = , .name = "format", .keywords =
@@ -1324,25 +1323,14 @@ notmuch_show_command (notmuch_config_t *config, 
unused(notmuch_database_t *notmu
fprintf (stderr, "Warning: --include-html only implemented for 
format=text, format=json and format=sexp\n");
 }
 
-notmuch_database_mode_t mode = NOTMUCH_DATABASE_MODE_READ_ONLY;
-if (params.crypto.decrypt == NOTMUCH_DECRYPT_TRUE)
-   mode = NOTMUCH_DATABASE_MODE_READ_WRITE;
-if (notmuch_database_open_with_config (NULL,
-  mode,
-  _notmuch_config_get_path (config),
-  NULL,
-  ,
-  _string)) {
-   if (status_string) {
-   fputs (status_string, stderr);
-   free (status_string);
+if (params.crypto.decrypt == NOTMUCH_DECRYPT_TRUE) {
+   status = notmuch_database_reopen (notmuch, 
NOTMUCH_DATABASE_MODE_READ_WRITE);
+   if (status) {
+   fprintf (stderr, "Error reopening database for READ_WRITE: %s\n", 
notmuch_status_to_string (status));
+   return EXIT_FAILURE;
}
-
-   return EXIT_FAILURE;
 }
 
-config = NULL;
-
 notmuch_exit_if_unmatched_db_uuid (notmuch);
 
 query_string = query_string_from_args (notmuch, argc - opt_index, argv + 
opt_index);
diff --git a/notmuch.c b/notmuch.c
index 7360e0e6..71482e43 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -152,7 +152,7 @@ static command_t commands[] = {
   "Search for messages matching the given search terms." },
 { "address", notmuch_address_command, NOTMUCH_COMMAND_DATABASE_EARLY,
   "Get addresses from messages matching the given search terms." },
-{ "show", notmuch_show_command, NOTMUCH_COMMAND_CONFIG_OPEN,
+{ "show", notmuch_show_command, NOTMUCH_COMMAND_DATABASE_EARLY,
   "Show all messages matching the search terms." },
 { "count", notmuch_count_command, NOTMUCH_COMMAND_DATABASE_EARLY,
   "Count messages matching the search terms." },
diff --git a/test/T035-read-config.sh b/test/T035-read-config.sh
index 205d1736..ac0f420b 100755
--- a/test/T035-read-config.sh
+++ b/test/T035-read-config.sh
@@ -378,7 +378,6 @@ restore_database
 test_expect_equal "$output" "OK"
 
 test_begin_subtest "show with alternate config (xdg)"
-test_subtest_known_broken
 backup_database
 notmuch tag -- +foobar17 '*'
 xdg_config
@@ -389,7 +388,6 @@ restore_config
 test_expect_equal "$output" "OK"
 
 test_begin_subtest "show with alternate config (xdg+profile)"
-test_subtest_known_broken
 backup_database
 notmuch tag -- +foobar17 '*'
 xdg_config foobar17
-- 
2.30.1
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org