]> git.ipfire.org Git - thirdparty/git.git/commitdiff
send-email: copy "config_regxp" into git-send-email.perl
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 28 May 2021 09:23:44 +0000 (11:23 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 28 May 2021 09:38:07 +0000 (18:38 +0900)
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 <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-send-email.perl

index e2fe112aa50ec6b0bf5d2c00226661cc27b9e9c0..73e3d3fd26e37bb167fae0610f2a0ec0b8c257c0 100755 (executable)
@@ -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");