From: David Bremner <david@tethera.net>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Subject: [PATCH v2] CLI: set NOTMUCH_CONFIG in hooks.
Date: Sat, 4 Jun 2022 08:11:19 -0300 [thread overview]
Message-ID: <20220604111119.3649737-1-david@tethera.net> (raw)
In-Reply-To: <20220530113820.2026574-2-david@tethera.net>
This addresses a bug report / feature request of Uwe Kleine-König. The
assumption is that we always load a config file in the CLI (i.e. we
never pass "" as the config file argument to
notmuch_database_open_with_config).
[1]: id:8baa58c3-7ab9-ec03-1bbd-28aa5be838f2@kleine-koenig.org
---
hooks.c | 7 +++++++
test/T400-hooks.sh | 4 ----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/hooks.c b/hooks.c
index ec89b22e..0cf72e74 100644
--- a/hooks.c
+++ b/hooks.c
@@ -27,6 +27,7 @@ int
notmuch_run_hook (notmuch_database_t *notmuch, const char *hook)
{
char *hook_path;
+ const char *config_path;
int status = 0;
pid_t pid;
@@ -38,6 +39,12 @@ notmuch_run_hook (notmuch_database_t *notmuch, const char *hook)
return 1;
}
+ config_path = notmuch_config_path (notmuch);
+ if (setenv ("NOTMUCH_CONFIG", config_path, 1)) {
+ perror ("setenv");
+ return 1;
+ }
+
/* Check access before fork() for speed and simplicity of error handling. */
if (access (hook_path, X_OK) == -1) {
/* Ignore ENOENT. It's okay not to have a hook, hook dir, or even
diff --git a/test/T400-hooks.sh b/test/T400-hooks.sh
index 9ceefbad..35bf70c0 100755
--- a/test/T400-hooks.sh
+++ b/test/T400-hooks.sh
@@ -215,9 +215,6 @@ EOF
test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "NOTMUCH_CONFIG is set"
- if [ "${config}" = "profile" ]; then
- test_subtest_known_broken
- fi
create_printenv_hook "pre-new" NOTMUCH_CONFIG OUTPUT
NOTMUCH_NEW
cat <<EOF > EXPECTED
@@ -226,7 +223,6 @@ EOF
test_expect_equal_file_nonempty EXPECTED OUTPUT
test_begin_subtest "NOTMUCH_CONFIG is set by --config"
- test_subtest_known_broken
create_printenv_hook "pre-new" NOTMUCH_CONFIG OUTPUT
cp "${EXPECTED_CONFIG}" "${EXPECTED_CONFIG}.alternate"
notmuch --config "${EXPECTED_CONFIG}.alternate" new
--
2.35.2
\r
next prev parent reply other threads:[~2022-06-04 11:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-30 11:38 [PATCH 1/2] test: add known broken tests for setting NOTMUCH_CONFIG in hooks David Bremner
2022-05-30 11:38 ` [PATCH 2/2] CLI: set " David Bremner
2022-06-04 11:11 ` David Bremner [this message]
2022-06-18 11:27 ` [PATCH v2] " David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220604111119.3649737-1-david@tethera.net \
--to=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).