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

7 messages from 2015-11-17 to 2015-11-24. Participants: John Keeping, Eric Sunshine, Jeff King.
Thread: https://gitlist.dev/t/40817

## John Keeping, 2015-11-17 22:01

Subject: [PATCH 0/2] send-email config path expansion
Message-ID: <cover.1447797487.git.john@keeping.me.uk>
URL: https://gitlist.dev/e/cover.1447797487.git.john%40keeping.me.uk

```
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, 2015-11-17 22:01

Subject: [PATCH 1/2] send-email: expand path in sendemail.smtpsslcertpath config
Message-ID: <5b9c60c07329ee166409f9d7f0b2ad4ad6e2dca3.1447797487.git.john@keeping.me.uk>
URL: https://gitlist.dev/e/5b9c60c07329ee166409f9d7f0b2ad4ad6e2dca3.1447797487.git.john%40keeping.me.uk
In-Reply-To: <cover.1447797487.git.john@keeping.me.uk>

```
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(-)

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, 2015-11-17 22:01

Subject: [PATCH 2/2] send-email: expand paths in sendemail.{to,cc}cmd config
Message-ID: <db0b817c4be57635248a48a529a32719ad232f02.1447797487.git.john@keeping.me.uk>
URL: https://gitlist.dev/e/db0b817c4be57635248a48a529a32719ad232f02.1447797487.git.john%40keeping.me.uk
In-Reply-To: <cover.1447797487.git.john@keeping.me.uk>

```
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(-)

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, 2015-11-24 00:04

Subject: Re: [PATCH 2/2] send-email: expand paths in sendemail.{to,cc}cmd config
Message-ID: <CAPig+cRY3W4VMgqnRuQFeMk7oueKsA=ZhMAk15LLyZg0KfVvCA@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcRY3W4VMgqnRuQFeMk7oueKsA%3DZhMAk15LLyZg0KfVvCA%40mail.gmail.com
In-Reply-To: <db0b817c4be57635248a48a529a32719ad232f02.1447797487.git.john@keeping.me.uk>

```
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'?

> 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, 2015-11-24 08:43

Subject: Re: [PATCH 2/2] send-email: expand paths in sendemail.{to,cc}cmd config
Message-ID: <20151124084353.GH21488@serenity.lan>
URL: https://gitlist.dev/e/20151124084353.GH21488%40serenity.lan
In-Reply-To: <CAPig+cRY3W4VMgqnRuQFeMk7oueKsA=ZhMAk15LLyZg0KfVvCA@mail.gmail.com>

```
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

> > 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, 2015-11-24 22:23

Subject: Re: [PATCH 2/2] send-email: expand paths in sendemail.{to,cc}cmd config
Message-ID: <20151124222330.GF29185@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20151124222330.GF29185%40sigill.intra.peff.net
In-Reply-To: <20151124084353.GH21488@serenity.lan>

```
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).

-Peff

```

## John Keeping, 2015-11-24 22:58

Subject: Re: [PATCH 2/2] send-email: expand paths in sendemail.{to,cc}cmd config
Message-ID: <20151124225824.GB18913@serenity.lan>
URL: https://gitlist.dev/e/20151124225824.GB18913%40serenity.lan
In-Reply-To: <20151124222330.GF29185@sigill.intra.peff.net>

```
On Tue, Nov 24, 2015 at 05:23:30PM -0500, Jeff King wrote:
> 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.

```
