Re: git-send-email: smtpserver in $HOME

3 messages, 3 authors, 2021-02-16 · open the first message on its own page

Re: git-send-email: smtpserver in $HOME

From: Junio C Hamano <hidden>
Date: 2021-02-16 02:15:29

Jan “Khardix” Staněk  [off-list ref] writes:
Would it be feasible to treat the `smtpserver` as path option
and expand `~`/`~user` paths?
Would it break anything
(i.e., is `~` a valid character for beginning of a hostname)?
I haven't given too much thought, but offhand do not think of a
reason why a change like the attached would break things.



 git-send-email.perl | 2 ++
 1 file changed, 2 insertions(+)
diff --git c/git-send-email.perl w/git-send-email.perl
index 1f425c0809..ff58ac5046 100755
--- c/git-send-email.perl
+++ w/git-send-email.perl
@@ -1006,6 +1006,8 @@ sub expand_one_alias {
 		}
 	}
 	$smtp_server ||= 'localhost'; # could be 127.0.0.1, too... *shrug*
+} elsif ($smtp_server =~ /^~/) {
+	$smtp_server = glob($smtp_server);
 }
 
 if ($compose && $compose > 0) {

Re: git-send-email: smtpserver in $HOME

From: Jan “Khardix” Staněk <hidden>
Date: 2021-02-16 12:50:08

On 2021-02-15, Junio C Hamano wrote:
I haven't given too much thought, but offhand do not think of a
reason why a change like the attached would break things.
Seems reasonable, but I figured I rather ask beforehand.
quoted hunk
 git-send-email.perl | 2 ++
 1 file changed, 2 insertions(+)
diff --git c/git-send-email.perl w/git-send-email.perl
index 1f425c0809..ff58ac5046 100755
--- c/git-send-email.perl
+++ w/git-send-email.perl
@@ -1006,6 +1006,8 @@ sub expand_one_alias {
 		}
 	}
 	$smtp_server ||= 'localhost'; # could be 127.0.0.1, too... *shrug*
+} elsif ($smtp_server =~ /^~/) {
+	$smtp_server = glob($smtp_server);
 }
This introduces a special case just for handling $smtp_server…
I was thinking something in the way of the following:
diff --git a/git-send-email.perl b/git-send-email.perl
index 1f425c0809..84c07daf6d 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -268,7 +268,6 @@ sub do_edit {
 );

 my %config_settings = (
-    "smtpserver" => \$smtp_server,
     "smtpserverport" => \$smtp_server_port,
     "smtpserveroption" => \@smtp_server_options,
     "smtpuser" => \$smtp_authuser,
@@ -294,6 +293,7 @@ sub do_edit {

 my %config_path_settings = (
     "aliasesfile" => \@alias_files,
+    "smtpserver" => \$smtp_server,
     "smtpsslcertpath" => \$smtp_ssl_cert_path,
 );
This turns the smtpserver option into a "path setting",
which does the user expansion.
My concern was that if there is a SMTP server actually named
i.e. `~someone.example.org`, this change would break that.
Of course, the question is if something like that
is possible or supported…

I have not yet allocated enough time to figure out how to run
and/or modify the test suite, so I do not know if this would actually
break something. I will try to do that in the near future.
--
Jan Staněk – Khardix

Re: git-send-email: smtpserver in $HOME

From: Jeff King <hidden>
Date: 2021-02-16 15:46:57

On Mon, Feb 15, 2021 at 06:14:39PM -0800, Junio C Hamano wrote:
Jan “Khardix” Staněk  [off-list ref] writes:
quoted
Would it be feasible to treat the `smtpserver` as path option
and expand `~`/`~user` paths?
Would it break anything
(i.e., is `~` a valid character for beginning of a hostname)?
I haven't given too much thought, but offhand do not think of a
reason why a change like the attached would break things.
I agree it's unlikely to break anything.

Still, it seems a bit unusual for an executed program to handle tilde
like this. The usual mechanism is for us to run it with the shell and
expect to find it in $PATH.

It looks like there's some weirdness here, though; $smtp_server may be a
hostname, and it looks like we use "/" to distinguish a file path. I
wonder if allowing "!my-sendmail" would be more consistent with other
parts of Git (not to mention more flexible).

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help