From: Drew DeVault <sir@cmpwn.com>
To: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Cc: Drew DeVault <sir@cmpwn.com>
Subject: [PATCH] git-send-email: die if sendmail.* config is set
Date: Sat, 18 Jul 2020 09:23:11 -0400 [thread overview]
Message-ID: <20200718132311.27248-1-sir@cmpwn.com> (raw)
I've seen several people mis-configure git send-email on their first
attempt because they set the sendmail.* config options - not
sendemail.*. This patch detects this mistake and bails out with a
friendly warning.
Signed-off-by: Drew DeVault <sir@cmpwn.com>
---
git-send-email.perl | 6 ++++++
perl/Git.pm | 26 ++++++++++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/git-send-email.perl b/git-send-email.perl
index 36c47bae1d..8e42ba00c1 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -478,6 +478,12 @@ sub read_config {
usage();
}
+if ((scalar Git::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" .
+ "Assuming this is a mistake and bailing out.\n");
+}
+
die __("Cannot run git format-patch from outside a repository\n")
if $format_patch and not $repo;
diff --git a/perl/Git.pm b/perl/Git.pm
index 54c9ed0dde..10df990959 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -723,6 +723,32 @@ sub config_int {
return scalar _config_common({'kind' => '--int'}, @_);
}
+=item config_regexp ( RE )
+
+Retrieve the list of configuration key names matching the regular
+expression C<RE>. The return value is a list of strings matching
+this regex.
+
+=cut
+
+sub config_regexp {
+ my ($self, $regex) = _maybe_self(@_);
+ try {
+ my @cmd = ('config', '--name-only', '--get-regexp', $regex);
+ unshift @cmd, $self if $self;
+ my @matches = command(@cmd);
+ return @matches;
+ } catch Git::Error::Command with {
+ my $E = shift;
+ if ($E->value() == 1) {
+ my @matches = ();
+ return @matches;
+ } else {
+ throw $E;
+ }
+ };
+}
+
# Common subroutine to implement bulk of what the config* family of methods
# do. This currently wraps command('config') so it is not so fast.
sub _config_common {
--
2.27.0
next reply other threads:[~2020-07-18 13:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-18 13:23 Drew DeVault [this message]
2020-07-18 18:02 ` [PATCH] git-send-email: die if sendmail.* config is set Junio C Hamano
2020-07-18 18:25 ` Drew DeVault
2020-07-18 20:10 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200718132311.27248-1-sir@cmpwn.com \
--to=sir@cmpwn.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox