git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v1] git-send-email: Respect core.hooksPath setting

From
Robert Foss <robert.foss@linaro.org>
Date
Mar 22, 2021, 16:20 UTC
Message-ID
<20210322162008.468779-1-robert.foss@linaro.org>

get-send-email currently makes the assumption that the 'sendemail-validate' hook exists inside of the repository.

Since the introduction of `core.hooksPath` configuration option in v2.9, this is no longer true.

Instead of assuming a hardcoded repo relative path, query git for the actual path of the hooks directory.

Signed-off-by: Robert Foss <robert.foss@linaro.org>
---

This patch does not include a test for this bug fix. This is entirely due to me not being able to think up a way to test this. So I'm very much open to suggestions.

 git-send-email.perl | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 1f425c0809..3934dceb70 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1942,8 +1942,9 @@ sub validate_patch {
 	my ($fn, $xfer_encoding) = @_;
 
 	if ($repo) {
-		my $validate_hook = catfile(catdir($repo->repo_path(), 'hooks'),
-					    'sendemail-validate');
+		my $hook_path = $repo->command('rev-parse', '--git-path', 'hooks');
+		chomp($hook_path);
+		my $validate_hook = catfile($hook_path, 'sendemail-validate');
 		my $hook_error;
 		if (-x $validate_hook) {
 			my $target = abs_path($fn);
-- 
2.27.0
Next: Ævar Arnfjörð Bjarmason
Message 1 of 3 in “git-send-email: Respect core.hooksPath setting”
  1. git-send-email: Respect core.hooksPath settingRobert Foss, Mar 22, 2021
  2. Ævar Arnfjörð BjarmasonMar 22, 2021
  3. Robert FossMar 22, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.