From 2b110e9ba255120a2d78a5d2cccc842519e341f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Fri, 28 May 2021 11:23:44 +0200 Subject: send-email: copy "config_regxp" into git-send-email.perl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The config_regexp() function was added in dd84e528a3 (git-send-email: die if sendmail.* config is set, 2020-07-23) for use in git-send-email, and it's the only in-tree user of it. However, the consensus is that Git.pm is a public interface, so even though it's a recently added function we can't change it. So let's copy over a minimal version of it to git-send-email.perl itself. In a subsequent commit it'll be changed further for our own use. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- git-send-email.perl | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index e2fe112aa5..73e3d3fd26 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -390,6 +390,24 @@ sub read_config { } } +sub config_regexp { + my ($regex) = @_; + my @ret; + eval { + @ret = Git::command( + 'config', + '--name-only', + '--get-regexp', + $regex, + ); + 1; + } or do { + # If we have no keys we're OK, otherwise re-throw + die $@ if $@->value != 1; + }; + return @ret; +} + # sendemail.identity yields to --identity. We must parse this # special-case first before the rest of the config is read. $identity = Git::config(@repo, "sendemail.identity"); @@ -488,7 +506,7 @@ unless ($rc) { usage(); } -if ($forbid_sendmail_variables && (scalar Git::config_regexp("^sendmail[.]")) != 0) { +if ($forbid_sendmail_variables && (scalar config_regexp("^sendmail[.]")) != 0) { die __("fatal: found configuration options for 'sendmail'\n" . "git-send-email is configured with the sendemail.* options - note the 'e'.\n" . "Set sendemail.forbidSendmailVariables to false to disable this check.\n"); -- cgit v1.2.3