Skip to content

Commit 2b110e9

Browse files
avargitster
authored andcommitted
send-email: copy "config_regxp" into git-send-email.perl
The config_regexp() function was added in dd84e52 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 119974e commit 2b110e9

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

git-send-email.perl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,24 @@ sub read_config {
390390
}
391391
}
392392

393+
sub config_regexp {
394+
my ($regex) = @_;
395+
my @ret;
396+
eval {
397+
@ret = Git::command(
398+
'config',
399+
'--name-only',
400+
'--get-regexp',
401+
$regex,
402+
);
403+
1;
404+
} or do {
405+
# If we have no keys we're OK, otherwise re-throw
406+
die $@ if $@->value != 1;
407+
};
408+
return @ret;
409+
}
410+
393411
# sendemail.identity yields to --identity. We must parse this
394412
# special-case first before the rest of the config is read.
395413
$identity = Git::config(@repo, "sendemail.identity");
@@ -488,7 +506,7 @@ sub read_config {
488506
usage();
489507
}
490508

491-
if ($forbid_sendmail_variables && (scalar Git::config_regexp("^sendmail[.]")) != 0) {
509+
if ($forbid_sendmail_variables && (scalar config_regexp("^sendmail[.]")) != 0) {
492510
die __("fatal: found configuration options for 'sendmail'\n" .
493511
"git-send-email is configured with the sendemail.* options - note the 'e'.\n" .
494512
"Set sendemail.forbidSendmailVariables to false to disable this check.\n");

0 commit comments

Comments
 (0)