threads / patch / 40817

patch, 2 partssend-email config path expansion

Subject: [PATCH 0/2] send-email config path expansion

## tl;dr

7 messages between Nov 17, 2015 and Nov 24, 2015. Diffs are folded; open one to read it.

replies: 6people: 3as markdown or json

John Keeping· Nov 17, 2015, 22:01 UTC · lore

These two patches enable tilde-expansion for a few more config variables in git-send-email.

The first case is the one that surprised me when it didn't work, the second two are the other ones that look like they should be handled as paths.

John Keeping (2):
  send-email: expand path in sendemail.smtpsslcertpath config
  send-email: expand paths in sendemail.{to,cc}cmd config
 git-send-email.perl | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
-- 
2.6.3.462.gbe2c914
John Keeping· Nov 17, 2015, 22:01 UTC · re: John Keeping · lore

[PATCH 1/2] send-email: expand path in sendemail.smtpsslcertpath config

As it says in the name, the SSL certificate path is a path so treat it as one and support tilde-expansion.

Signed-off-by: John Keeping <john@keeping.me.uk>
---
 git-send-email.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to git-send-email.perl +1 −1
diff --git a/git-send-email.perl b/git-send-email.perl
index e907e0e..719c715 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -239,7 +239,6 @@ my %config_settings = (
     "smtpserveroption" => \@smtp_server_options,
     "smtpuser" => \$smtp_authuser,
     "smtppass" => \$smtp_authpass,
-    "smtpsslcertpath" => \$smtp_ssl_cert_path,
     "smtpdomain" => \$smtp_domain,
     "smtpauth" => \$smtp_auth,
     "to" => \@initial_to,
@@ -259,6 +258,7 @@ my %config_settings = (
 
 my %config_path_settings = (
     "aliasesfile" => \@alias_files,
+    "smtpsslcertpath" => \$smtp_ssl_cert_path,
 );
 
 # Handle Uncouth Termination
-- 
2.6.3.462.gbe2c914
John Keeping· Nov 17, 2015, 22:01 UTC · re: John Keeping · lore

[PATCH 2/2] send-email: expand paths in sendemail.{to,cc}cmd config

These configuration variables specify the paths to commands so we should support tilde-expansion for files inside a user's home directory.

Signed-off-by: John Keeping <john@keeping.me.uk>
---
 git-send-email.perl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Show changes to git-send-email.perl +2 −2
diff --git a/git-send-email.perl b/git-send-email.perl
index 719c715..8e4c0e1 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -242,9 +242,7 @@ my %config_settings = (
     "smtpdomain" => \$smtp_domain,
     "smtpauth" => \$smtp_auth,
     "to" => \@initial_to,
-    "tocmd" => \$to_cmd,
     "cc" => \@initial_cc,
-    "cccmd" => \$cc_cmd,
     "aliasfiletype" => \$aliasfiletype,
     "bcc" => \@bcclist,
     "suppresscc" => \@suppress_cc,
@@ -259,6 +257,8 @@ my %config_settings = (
 my %config_path_settings = (
     "aliasesfile" => \@alias_files,
     "smtpsslcertpath" => \$smtp_ssl_cert_path,
+    "tocmd" => \$to_cmd,
+    "cccmd" => \$cc_cmd,
 );
 
 # Handle Uncouth Termination
-- 
2.6.3.462.gbe2c914
Eric Sunshine· Nov 24, 2015, 00:04 UTC · re: John Keeping · lore

Re: [PATCH 2/2] send-email: expand paths in sendemail.{to,cc}cmd config

On Tue, Nov 17, 2015 at 5:01 PM, John Keeping <john@keeping.me.uk> wrote:
> These configuration variables specify the paths to commands so we should
> support tilde-expansion for files inside a user's home directory.

Hmm, I don't see anything in the documentation which says that these are paths to commands, and the code itself treats them purely as commands to be invoked, not as paths to commands. What is the behavior, for instance, with --tocmd='foobar -x zopp' or even --tocmd='foobar -x ~/zopp'?

Show 23 quoted lines
> Signed-off-by: John Keeping <john@keeping.me.uk>
> ---
> diff --git a/git-send-email.perl b/git-send-email.perl
> index 719c715..8e4c0e1 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -242,9 +242,7 @@ my %config_settings = (
>      "smtpdomain" => \$smtp_domain,
>      "smtpauth" => \$smtp_auth,
>      "to" => \@initial_to,
> -    "tocmd" => \$to_cmd,
>      "cc" => \@initial_cc,
> -    "cccmd" => \$cc_cmd,
>      "aliasfiletype" => \$aliasfiletype,
>      "bcc" => \@bcclist,
>      "suppresscc" => \@suppress_cc,
> @@ -259,6 +257,8 @@ my %config_settings = (
>  my %config_path_settings = (
>      "aliasesfile" => \@alias_files,
>      "smtpsslcertpath" => \$smtp_ssl_cert_path,
> +    "tocmd" => \$to_cmd,
> +    "cccmd" => \$cc_cmd,
>  );
John Keeping· Nov 24, 2015, 08:43 UTC · re: Eric Sunshine · lore

Re: [PATCH 2/2] send-email: expand paths in sendemail.{to,cc}cmd config

On Mon, Nov 23, 2015 at 07:04:46PM -0500, Eric Sunshine wrote:
Show 9 quoted lines
> On Tue, Nov 17, 2015 at 5:01 PM, John Keeping <john@keeping.me.uk> wrote:
> > These configuration variables specify the paths to commands so we should
> > support tilde-expansion for files inside a user's home directory.
> 
> Hmm, I don't see anything in the documentation which says that these
> are paths to commands, and the code itself treats them purely as
> commands to be invoked, not as paths to commands. What is the
> behavior, for instance, with --tocmd='foobar -x zopp' or even
> --tocmd='foobar -x ~/zopp'?

The path behaviour only expands leading '~' and '~user' (as documented in git-config(1)):

	$ git -c sendemail.tocmd='foobar -x ~/zopp' config --path sendemail.tocmd
	foobar -x ~/zopp
Show 23 quoted lines
> > Signed-off-by: John Keeping <john@keeping.me.uk>
> > ---
> > diff --git a/git-send-email.perl b/git-send-email.perl
> > index 719c715..8e4c0e1 100755
> > --- a/git-send-email.perl
> > +++ b/git-send-email.perl
> > @@ -242,9 +242,7 @@ my %config_settings = (
> >      "smtpdomain" => \$smtp_domain,
> >      "smtpauth" => \$smtp_auth,
> >      "to" => \@initial_to,
> > -    "tocmd" => \$to_cmd,
> >      "cc" => \@initial_cc,
> > -    "cccmd" => \$cc_cmd,
> >      "aliasfiletype" => \$aliasfiletype,
> >      "bcc" => \@bcclist,
> >      "suppresscc" => \@suppress_cc,
> > @@ -259,6 +257,8 @@ my %config_settings = (
> >  my %config_path_settings = (
> >      "aliasesfile" => \@alias_files,
> >      "smtpsslcertpath" => \$smtp_ssl_cert_path,
> > +    "tocmd" => \$to_cmd,
> > +    "cccmd" => \$cc_cmd,
> >  );
Jeff King· Nov 24, 2015, 22:23 UTC · re: John Keeping · lore

Re: [PATCH 2/2] send-email: expand paths in sendemail.{to,cc}cmd config

On Tue, Nov 24, 2015 at 08:43:53AM +0000, John Keeping wrote:
Show 16 quoted lines
> On Mon, Nov 23, 2015 at 07:04:46PM -0500, Eric Sunshine wrote:
> > On Tue, Nov 17, 2015 at 5:01 PM, John Keeping <john@keeping.me.uk> wrote:
> > > These configuration variables specify the paths to commands so we should
> > > support tilde-expansion for files inside a user's home directory.
> > 
> > Hmm, I don't see anything in the documentation which says that these
> > are paths to commands, and the code itself treats them purely as
> > commands to be invoked, not as paths to commands. What is the
> > behavior, for instance, with --tocmd='foobar -x zopp' or even
> > --tocmd='foobar -x ~/zopp'?
> 
> The path behaviour only expands leading '~' and '~user' (as documented
> in git-config(1)):
> 
> 	$ git -c sendemail.tocmd='foobar -x ~/zopp' config --path sendemail.tocmd
> 	foobar -x ~/zopp

We usually run user-supplied commands with a shell (and AFAICT, that is the case here). So wouldn't that turn into (when used by send-email):

  sh -c 'foobar -x ~/zopp'
and the shell would expand it for us? Running:
  git -c sendemail.tocmd='echo ~/foo' send-email -1
seems to work for me (it puts "/home/peff/foo" into the "to" header).
-Peff
John Keeping· Nov 24, 2015, 22:58 UTC · re: Jeff King · lore

Re: [PATCH 2/2] send-email: expand paths in sendemail.{to,cc}cmd config

On Tue, Nov 24, 2015 at 05:23:30PM -0500, Jeff King wrote:
Show 29 quoted lines
> On Tue, Nov 24, 2015 at 08:43:53AM +0000, John Keeping wrote:
> 
> > On Mon, Nov 23, 2015 at 07:04:46PM -0500, Eric Sunshine wrote:
> > > On Tue, Nov 17, 2015 at 5:01 PM, John Keeping <john@keeping.me.uk> wrote:
> > > > These configuration variables specify the paths to commands so we should
> > > > support tilde-expansion for files inside a user's home directory.
> > > 
> > > Hmm, I don't see anything in the documentation which says that these
> > > are paths to commands, and the code itself treats them purely as
> > > commands to be invoked, not as paths to commands. What is the
> > > behavior, for instance, with --tocmd='foobar -x zopp' or even
> > > --tocmd='foobar -x ~/zopp'?
> > 
> > The path behaviour only expands leading '~' and '~user' (as documented
> > in git-config(1)):
> > 
> > 	$ git -c sendemail.tocmd='foobar -x ~/zopp' config --path sendemail.tocmd
> > 	foobar -x ~/zopp
> 
> We usually run user-supplied commands with a shell (and AFAICT, that is
> the case here). So wouldn't that turn into (when used by send-email):
> 
>   sh -c 'foobar -x ~/zopp'
> 
> and the shell would expand it for us? Running:
> 
>   git -c sendemail.tocmd='echo ~/foo' send-email -1
> 
> seems to work for me (it puts "/home/peff/foo" into the "to" header).
Ah, I hadn't tested it.  We can drop this patch then.

← back to recent threads