{"thread":{"id":"55664","subject":"[PATCH v3] git-send-email: use ! to indicate relative path to command","startedAt":"2021-05-11T19:15:48Z","lastAt":"2021-05-12T04:17:19Z","messageCount":23,"participants":["Gregory Anders","Jeff King","Felipe Contreras","Junio C Hamano","brian m. carlson"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"424183","messageId":"20210511191510.25888-1-greg@gpanders.com","threadId":"55664","inReplyTo":null,"subject":"[PATCH v3] git-send-email: use ! to indicate relative path to command","fromName":"Gregory Anders","fromEmail":"greg@gpanders.com","sentAt":"2021-05-11T19:15:11Z","receivedAt":"2021-05-11T19:15:48Z","isPatch":true,"sender":{"key":"greg@gpanders.com","avatar":"https://avatars.githubusercontent.com/u/8965202?v=4"},"body":"When the smtpServer config option is prefixed with a ! character, the\nvalue of the option should be interpreted as a command to look up on\nPATH.\n\nSigned-off-by: Gregory Anders <greg@gpanders.com>\n---\n\nRemove the PATH lookup, since Perl's exec() does this already.\n\nThanks to Jeff King for the assist.\n\n git-send-email.perl | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 175da07d94..022dcf0999 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1492,11 +1492,14 @@ sub send_message {\n \n \tif ($dry_run) {\n \t\t# We don't want to send the email.\n-\t} elsif (file_name_is_absolute($smtp_server)) {\n+\t} elsif (file_name_is_absolute($smtp_server) || $smtp_server =~ /^!/) {\n+\t\tmy $prog = $smtp_server;\n+\t\t$prog =~ s/^!//;\n+\n \t\tmy $pid = open my $sm, '|-';\n \t\tdefined $pid or die $!;\n \t\tif (!$pid) {\n-\t\t\texec($smtp_server, @sendmail_parameters) or die $!;\n+\t\t\texec($prog, @sendmail_parameters) or die $!;\n \t\t}\n \t\tprint $sm \"$header\\n$message\";\n \t\tclose $sm or die $!;\n-- \n2.31.1.576.g06d230b258\n\n"},{"id":"424186","messageId":"YJrZ7Hho6jrVyM7f@coredump.intra.peff.net","threadId":"55664","inReplyTo":"20210511191510.25888-1-greg@gpanders.com","subject":"Re: [PATCH v3] git-send-email: use ! to indicate relative path to command","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-05-11T19:24:28Z","receivedAt":"2021-05-11T19:24:30Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, May 11, 2021 at 01:15:11PM -0600, Gregory Anders wrote:\n\n> When the smtpServer config option is prefixed with a ! character, the\n> value of the option should be interpreted as a command to look up on\n> PATH.\n\nThis tells us \"what\", but the commit message is a good place to describe\n\"why\". That helps reviewers now understand what you're trying to\naccomplish, and why this is a good way to do it rather than some other\npatch.\n\nIMHO the most important \"why\" here is that there currently is no way to\nspecify a local smtp server program without using a full path.\n\nI think this is a good direction to fix it, though for anybody just\nseeing this patch, I'd call attention to the nearby thread (and the one\nit links to):\n\n  https://lore.kernel.org/git/YJrH8uqzapnpNEsb@gpanders.com/\n\n>  git-send-email.perl | 7 +++++--\n>  1 file changed, 5 insertions(+), 2 deletions(-)\n\nWe'd probably want a test here, as well; see t/t9001-send-email.sh.\n\nWe implicitly test the absolute-path behavior in that script because\npass \"--smtp-server=$(pwd)/fake.sendmail\" in lots of places. But we'd\nprobably want a new test block that checks that:\n\n  PATH=$(pwd):$PATH \\\n  git send-email --smtp-server=\"!fake.sendmail\"\n\ndoes what you expect.\n\n-Peff\n"},{"id":"424191","messageId":"609ae32e3b9f_60649208e0@natae.notmuch","threadId":"55664","inReplyTo":"20210511191510.25888-1-greg@gpanders.com","subject":"RE: [PATCH v3] git-send-email: use ! to indicate relative path to command","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-11T20:03:58Z","receivedAt":"2021-05-11T20:04:02Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Gregory Anders wrote:\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -1492,11 +1492,14 @@ sub send_message {\n>  \n>  \tif ($dry_run) {\n>  \t\t# We don't want to send the email.\n> -\t} elsif (file_name_is_absolute($smtp_server)) {\n> +\t} elsif (file_name_is_absolute($smtp_server) || $smtp_server =~ /^!/) {\n\nIs there any particular reason why we are checking for an absolute path?\n\n-- \nFelipe Contreras\n"},{"id":"424198","messageId":"20210511204044.69047-1-greg@gpanders.com","threadId":"55664","inReplyTo":"YJrZ7Hho6jrVyM7f@coredump.intra.peff.net","subject":"[PATCH v4] git-send-email: use ! to indicate relative path to command","fromName":"Gregory Anders","fromEmail":"greg@gpanders.com","sentAt":"2021-05-11T20:40:44Z","receivedAt":"2021-05-11T20:40:58Z","isPatch":true,"sender":{"key":"greg@gpanders.com","avatar":"https://avatars.githubusercontent.com/u/8965202?v=4"},"body":"Presently, the smtpServer config option can use a sendmail-like program\nby providing an absolute path to the program as the value for this\noption. However, an absolute path is not always portable and it is often\npreferable to simply specify a program name and have `git-send-email`\nfind that program on $PATH.\n\nFor example, if a user wishes to use msmtp to send emails, they might\nbe able to simply use\n\n    [sendemail]\n            smtpServer = !msmtp\n\ninstead of using the full path. This is particularly useful when a\ncommon git config file is used across multiple systems where the\nabsolute path to a given program may differ.\n\nTo that end, this patch allows the smtpServer config option to be\nprefixed with a ! character that implements the above behavior; namely,\nthe specified value (sans the ! character) is used as if the user had\nentered it directly on the command line.\n\nSee also https://lore.kernel.org/git/YJrH8uqzapnpNEsb@gpanders.com/.\n\nSigned-off-by: Gregory Anders <greg@gpanders.com>\n---\n Documentation/git-send-email.txt | 13 +++++++------\n git-send-email.perl              |  7 +++++--\n t/t9001-send-email.sh            | 10 ++++++++++\n 3 files changed, 22 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 93708aefea..418e66c703 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -212,12 +212,13 @@ a password is obtained using 'git-credential'.\n --smtp-server=<host>::\n \tIf set, specifies the outgoing SMTP server to use (e.g.\n \t`smtp.example.com` or a raw IP address).  Alternatively it can\n-\tspecify a full pathname of a sendmail-like program instead;\n-\tthe program must support the `-i` option.  Default value can\n-\tbe specified by the `sendemail.smtpServer` configuration\n-\toption; the built-in default is to search for `sendmail` in\n-\t`/usr/sbin`, `/usr/lib` and $PATH if such program is\n-\tavailable, falling back to `localhost` otherwise.\n+\tspecify a sendmail-like program instead, either by a full\n+\tpath-name or by prefixing the program name with `!`.  The\n+\tprogram must support the `-i` option.  Default value can be\n+\tspecified by the `sendemail.smtpServer` configuration option;\n+\tthe built-in default is to search for `sendmail` in `/usr/sbin`,\n+\t`/usr/lib` and $PATH if such program is available, falling back\n+\tto `localhost` otherwise.\n \n --smtp-server-port=<port>::\n \tSpecifies a port different from the default port (SMTP\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 175da07d94..022dcf0999 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1492,11 +1492,14 @@ sub send_message {\n \n \tif ($dry_run) {\n \t\t# We don't want to send the email.\n-\t} elsif (file_name_is_absolute($smtp_server)) {\n+\t} elsif (file_name_is_absolute($smtp_server) || $smtp_server =~ /^!/) {\n+\t\tmy $prog = $smtp_server;\n+\t\t$prog =~ s/^!//;\n+\n \t\tmy $pid = open my $sm, '|-';\n \t\tdefined $pid or die $!;\n \t\tif (!$pid) {\n-\t\t\texec($smtp_server, @sendmail_parameters) or die $!;\n+\t\t\texec($prog, @sendmail_parameters) or die $!;\n \t\t}\n \t\tprint $sm \"$header\\n$message\";\n \t\tclose $sm or die $!;\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 65b3035371..14cc61ace7 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -2225,4 +2225,14 @@ test_expect_success $PREREQ 'test forbidSendmailVariables behavior override' '\n \t\tHEAD^\n '\n \n+test_expect_success $PREREQ 'test using a command for smtpServer with !' '\n+\tclean_fake_sendmail &&\n+\tPATH=\"$(pwd):$PATH\" \\\n+\tgit send-email \\\n+\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t--to=nobody@example.com \\\n+\t\t--smtp-server=\"!fake.sendmail\" \\\n+\t\t$patches 2>errors\n+'\n+\n test_done\n-- \n2.31.1.576.g2f8a831619\n\n"},{"id":"424199","messageId":"YJrsTu5YtGNpQvZh@gpanders.com","threadId":"55664","inReplyTo":"609ae32e3b9f_60649208e0@natae.notmuch","subject":"Re: [PATCH v3] git-send-email: use ! to indicate relative path to command","fromName":"Gregory Anders","fromEmail":"greg@gpanders.com","sentAt":"2021-05-11T20:42:54Z","receivedAt":"2021-05-11T20:43:00Z","isPatch":true,"sender":{"key":"greg@gpanders.com","avatar":"https://avatars.githubusercontent.com/u/8965202?v=4"},"body":"On Tue, 11 May 2021 15:03 -0500, Felipe Contreras wrote:\n>Is there any particular reason why we are checking for an absolute \n>path?\n\nThe existing behavior is that the value of smtpServer is a hostname of a \nserver, *unless* it is an absolute path in which case it is interpreted \nas a program to use to send the mail (e.g. a sendmail alternative or \nmsmtp).\n"},{"id":"424211","messageId":"YJr5rHnQOve1DD6+@coredump.intra.peff.net","threadId":"55664","inReplyTo":"20210511204044.69047-1-greg@gpanders.com","subject":"Re: [PATCH v4] git-send-email: use ! to indicate relative path to command","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-05-11T21:39:56Z","receivedAt":"2021-05-11T21:39:58Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, May 11, 2021 at 02:40:44PM -0600, Gregory Anders wrote:\n\n> Presently, the smtpServer config option can use a sendmail-like program\n> by providing an absolute path to the program as the value for this\n> option. However, an absolute path is not always portable and it is often\n> preferable to simply specify a program name and have `git-send-email`\n> find that program on $PATH.\n> \n> For example, if a user wishes to use msmtp to send emails, they might\n> be able to simply use\n> \n>     [sendemail]\n>             smtpServer = !msmtp\n> \n> instead of using the full path. This is particularly useful when a\n> common git config file is used across multiple systems where the\n> absolute path to a given program may differ.\n> \n> To that end, this patch allows the smtpServer config option to be\n> prefixed with a ! character that implements the above behavior; namely,\n> the specified value (sans the ! character) is used as if the user had\n> entered it directly on the command line.\n\nThanks, this justifies the change quite nicely, I think.\n\n> See also https://lore.kernel.org/git/YJrH8uqzapnpNEsb@gpanders.com/.\n\nIMHO this link could be dropped. I referenced it earlier in the thread\nsince there wasn't much context in your commit message. In general we\nprefer to copy that context into the commit, so it doesn't depend on\nhaving access to the list. And you already did that quite nicely, so the\nlink tells us nothing new. :)\n\n> diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\n> index 93708aefea..418e66c703 100644\n> --- a/Documentation/git-send-email.txt\n> +++ b/Documentation/git-send-email.txt\n> @@ -212,12 +212,13 @@ a password is obtained using 'git-credential'.\n>  --smtp-server=<host>::\n>  \tIf set, specifies the outgoing SMTP server to use (e.g.\n>  \t`smtp.example.com` or a raw IP address).  Alternatively it can\n> -\tspecify a full pathname of a sendmail-like program instead;\n> -\tthe program must support the `-i` option.  Default value can\n> -\tbe specified by the `sendemail.smtpServer` configuration\n> -\toption; the built-in default is to search for `sendmail` in\n> -\t`/usr/sbin`, `/usr/lib` and $PATH if such program is\n> -\tavailable, falling back to `localhost` otherwise.\n> +\tspecify a sendmail-like program instead, either by a full\n> +\tpath-name or by prefixing the program name with `!`.  The\n> +\tprogram must support the `-i` option.  Default value can be\n> +\tspecified by the `sendemail.smtpServer` configuration option;\n> +\tthe built-in default is to search for `sendmail` in `/usr/sbin`,\n> +\t`/usr/lib` and $PATH if such program is available, falling back\n> +\tto `localhost` otherwise.\n\nAh, thanks for remembering to update the documentation. This looks good.\n\n> diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\n> index 65b3035371..14cc61ace7 100755\n> --- a/t/t9001-send-email.sh\n> +++ b/t/t9001-send-email.sh\n> @@ -2225,4 +2225,14 @@ test_expect_success $PREREQ 'test forbidSendmailVariables behavior override' '\n>  \t\tHEAD^\n>  '\n>  \n> +test_expect_success $PREREQ 'test using a command for smtpServer with !' '\n> +\tclean_fake_sendmail &&\n> +\tPATH=\"$(pwd):$PATH\" \\\n> +\tgit send-email \\\n> +\t\t--from=\"Example <nobody@example.com>\" \\\n> +\t\t--to=nobody@example.com \\\n> +\t\t--smtp-server=\"!fake.sendmail\" \\\n> +\t\t$patches 2>errors\n> +'\n\nHow do we know that we successfully ran our fake.sendmail script? I\nguess probably send-email would error out, but should we confirm that it\ntouched commandline1, etc?\n\nIt also seems to fail for me. I think $patches isn't valid at this point\nin the script, as the patch files have been removed. Switching to just\nHEAD~2 doesn't seem to work either, as earlier tests set up a hook which\nrejects it. I think we could pass HEAD^ to send just one path, but I\nthought it would be nice to confirm that sending multiple works (i.e.,\navoiding the bug we discussed earlier).\n\nI think the existing hook tests are somewhat poor to leave this\nconfusing state. But the easiest thing to me is to just bump our test up\na bit, like:\n\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 14cc61ace7..31d25b32b5 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -2148,6 +2148,18 @@ test_expect_success $PREREQ 'leading and trailing whitespaces are removed' '\n \ttest_cmp expected-list actual-list\n '\n \n+test_expect_success $PREREQ 'test using a command for smtpServer with !' '\n+\tclean_fake_sendmail &&\n+\tPATH=\"$(pwd):$PATH\" \\\n+\tgit send-email \\\n+\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t--to=nobody@example.com \\\n+\t\t--smtp-server=\"!fake.sendmail\" \\\n+\t\tHEAD~2 2>errors &&\n+\ttest_path_is_file commandline1 &&\n+\ttest_path_is_file commandline2\n+'\n+\n test_expect_success $PREREQ 'invoke hook' '\n \tmkdir -p .git/hooks &&\n \n@@ -2225,14 +2237,4 @@ test_expect_success $PREREQ 'test forbidSendmailVariables behavior override' '\n \t\tHEAD^\n '\n \n-test_expect_success $PREREQ 'test using a command for smtpServer with !' '\n-\tclean_fake_sendmail &&\n-\tPATH=\"$(pwd):$PATH\" \\\n-\tgit send-email \\\n-\t\t--from=\"Example <nobody@example.com>\" \\\n-\t\t--to=nobody@example.com \\\n-\t\t--smtp-server=\"!fake.sendmail\" \\\n-\t\t$patches 2>errors\n-'\n-\n test_done\n"},{"id":"424212","messageId":"609b0017a323b_6064920888@natae.notmuch","threadId":"55664","inReplyTo":"YJrsTu5YtGNpQvZh@gpanders.com","subject":"Re: [PATCH v3] git-send-email: use ! to indicate relative path to command","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-11T22:07:19Z","receivedAt":"2021-05-11T22:07:25Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Gregory Anders wrote:\n> On Tue, 11 May 2021 15:03 -0500, Felipe Contreras wrote:\n> >Is there any particular reason why we are checking for an absolute \n> >path?\n> \n> The existing behavior is that the value of smtpServer is a hostname of a \n> server, *unless* it is an absolute path in which case it is interpreted \n> as a program to use to send the mail (e.g. a sendmail alternative or \n> msmtp).\n\nI see. That's unfortunate.\n\nIt would be much better to have sendemail.program, and then we wouldn't\nneedto deal with these workarounds.\n\n-- \nFelipe Contreras\n"},{"id":"424213","messageId":"YJsCslVJhcGANb13@gpanders.com","threadId":"55664","inReplyTo":"YJr5rHnQOve1DD6+@coredump.intra.peff.net","subject":"Re: [PATCH v4] git-send-email: use ! to indicate relative path to command","fromName":"Gregory Anders","fromEmail":"greg@gpanders.com","sentAt":"2021-05-11T22:18:26Z","receivedAt":"2021-05-11T22:18:32Z","isPatch":true,"sender":{"key":"greg@gpanders.com","avatar":"https://avatars.githubusercontent.com/u/8965202?v=4"},"body":"On Tue, 11 May 2021 17:39 -0400, Jeff King wrote:\n>It also seems to fail for me. I think $patches isn't valid at this \n>point in the script, as the patch files have been removed. Switching to \n>just HEAD~2 doesn't seem to work either, as earlier tests set up a hook \n>which rejects it. I think we could pass HEAD^ to send just one path, \n>but I thought it would be nice to confirm that sending multiple works \n>(i.e., avoiding the bug we discussed earlier).\n\nI had to play around with this too (being unfamiliar with how this test \nharness worked). It would pass if I ran the first ~20 tests (20 is not \nsignificant, it's just a number I chose to ensure that whatever \nnecessary setup needed to happen was done), but would fail otherwise. \nMoving the test up seems fine, I put it at the bottom simply because I \nwasn't sure where else to put it.\n"},{"id":"424214","messageId":"YJsDAnHcnro6Gfk4@gpanders.com","threadId":"55664","inReplyTo":"609b0017a323b_6064920888@natae.notmuch","subject":"Re: [PATCH v3] git-send-email: use ! to indicate relative path to command","fromName":"Gregory Anders","fromEmail":"greg@gpanders.com","sentAt":"2021-05-11T22:19:46Z","receivedAt":"2021-05-11T22:19:51Z","isPatch":true,"sender":{"key":"greg@gpanders.com","avatar":"https://avatars.githubusercontent.com/u/8965202?v=4"},"body":"On Tue, 11 May 2021 17:07 -0500, Felipe Contreras wrote:\n>It would be much better to have sendemail.program, and then we wouldn't\n>need to deal with these workarounds.\n\nFrankly I agree. Should I modify my patch to add this new option instead \nof modifying the behavior of smtpServer? Obviously the smtpServer option \nwould need to preserve its current behavior for backward compatibility.\n"},{"id":"424221","messageId":"xmqqk0o4j2ax.fsf@gitster.g","threadId":"55664","inReplyTo":"20210511204044.69047-1-greg@gpanders.com","subject":"Re: [PATCH v4] git-send-email: use ! to indicate relative path to command","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-05-11T23:09:10Z","receivedAt":"2021-05-11T23:09:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Gregory Anders <greg@gpanders.com> writes:\n\n> Presently, the smtpServer config option can use a sendmail-like program\n\ns/Presently, t/T/;  Also if I understand it correctly this is not\njust about configuration varible but equally applies to the command\nline option --smtp-server, so mention both of them in their full\nname, i.e.\n\n    The sendemail.smtpServer configuration variable and the\n    \"--smtp-server\" command line option can name a program to use by\n    providing ...\n\n> by providing an absolute path to the program as the value for this\n> option. However, an absolute path is not always portable and it is often\n> preferable to simply specify a program name and have `git-send-email`\n> find that program on $PATH.\n>\n> For example, if a user wishes to use msmtp to send emails, they might\n> be able to simply use\n>\n>     [sendemail]\n>             smtpServer = !msmtp\n>\n> instead of using the full path. This is particularly useful when a\n> common git config file is used across multiple systems where the\n> absolute path to a given program may differ.\n\nNicely explained.\n\n> To that end, this patch allows the smtpServer config option to be\n> prefixed with a ! character that implements the above behavior; namely,\n> the specified value (sans the ! character) is used as if the user had\n> entered it directly on the command line.\n\n\tAllow the value of the configuration variable and the\n\tcommand line option to be prefixed with a '!' to signal that\n\tthe specified command needs to be looked up on $PATH.\n\n> See also https://lore.kernel.org/git/YJrH8uqzapnpNEsb@gpanders.com/.\n\nYou summarised the problem description in that message pretty well\nin the proposed log message (which is much better than leaving only\na URL and forcing readers to go there), and I suspect there aren't\nmuch readers can learn from by seeing also the article, though.\n\n> +\t} elsif (file_name_is_absolute($smtp_server) || $smtp_server =~ /^!/) {\n> +\t\tmy $prog = $smtp_server;\n> +\t\t$prog =~ s/^!//;\n> +\n>  \t\tmy $pid = open my $sm, '|-';\n>  \t\tdefined $pid or die $!;\n>  \t\tif (!$pid) {\n> -\t\t\texec($smtp_server, @sendmail_parameters) or die $!;\n> +\t\t\texec($prog, @sendmail_parameters) or die $!;\n>  \t\t}\n\nLooking good.\n\nThanks.\n"},{"id":"424227","messageId":"20210511234935.65147-1-greg@gpanders.com","threadId":"55664","inReplyTo":"20210511204044.69047-1-greg@gpanders.com","subject":"[PATCH v5] git-send-email: use ! to indicate relative path to command","fromName":"Gregory Anders","fromEmail":"greg@gpanders.com","sentAt":"2021-05-11T23:49:35Z","receivedAt":"2021-05-11T23:51:56Z","isPatch":true,"sender":{"key":"greg@gpanders.com","avatar":"https://avatars.githubusercontent.com/u/8965202?v=4"},"body":"The sendemail.smtpServer configuration option and the '--smtp-server'\ncommand line option can name a program to use by providing an absolute\npath to the program. However, an absolute path is not always portable\nand it is often preferable to simply specify a program name and have\n'git-send-email' find that program on $PATH.\n\nFor example, if a user wishes to use msmtp to send emails, they might\nbe able to simply use\n\n    [sendemail]\n            smtpServer = !msmtp\n\ninstead of using the full path. This is particularly useful when a\ncommon git config file is used across multiple systems where the\nabsolute path to a given program may differ.\n\nTo that end, this patch allows both the configuration and command line\noptions to be prefixed with a '!' character to indicate that the\nspecified command should be found on $PATH, as if the user had entered\nit directly on the command line.\n\nSigned-off-by: Gregory Anders <greg@gpanders.com>\n---\nDiff from v4:\n\n* Update the test with suggestions from Jeff King (this should fix \n  erroneous test failures caused by patch files being deleted by earlier \n  tests)\n* Reword the commit message with feedback from Jeff King and Junio \n  Hamano\n\n Documentation/git-send-email.txt | 13 +++++++------\n git-send-email.perl              |  7 +++++--\n t/t9001-send-email.sh            | 12 ++++++++++++\n 3 files changed, 24 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 93708aefea..418e66c703 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -212,12 +212,13 @@ a password is obtained using 'git-credential'.\n --smtp-server=<host>::\n \tIf set, specifies the outgoing SMTP server to use (e.g.\n \t`smtp.example.com` or a raw IP address).  Alternatively it can\n-\tspecify a full pathname of a sendmail-like program instead;\n-\tthe program must support the `-i` option.  Default value can\n-\tbe specified by the `sendemail.smtpServer` configuration\n-\toption; the built-in default is to search for `sendmail` in\n-\t`/usr/sbin`, `/usr/lib` and $PATH if such program is\n-\tavailable, falling back to `localhost` otherwise.\n+\tspecify a sendmail-like program instead, either by a full\n+\tpath-name or by prefixing the program name with `!`.  The\n+\tprogram must support the `-i` option.  Default value can be\n+\tspecified by the `sendemail.smtpServer` configuration option;\n+\tthe built-in default is to search for `sendmail` in `/usr/sbin`,\n+\t`/usr/lib` and $PATH if such program is available, falling back\n+\tto `localhost` otherwise.\n \n --smtp-server-port=<port>::\n \tSpecifies a port different from the default port (SMTP\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 175da07d94..022dcf0999 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1492,11 +1492,14 @@ sub send_message {\n \n \tif ($dry_run) {\n \t\t# We don't want to send the email.\n-\t} elsif (file_name_is_absolute($smtp_server)) {\n+\t} elsif (file_name_is_absolute($smtp_server) || $smtp_server =~ /^!/) {\n+\t\tmy $prog = $smtp_server;\n+\t\t$prog =~ s/^!//;\n+\n \t\tmy $pid = open my $sm, '|-';\n \t\tdefined $pid or die $!;\n \t\tif (!$pid) {\n-\t\t\texec($smtp_server, @sendmail_parameters) or die $!;\n+\t\t\texec($prog, @sendmail_parameters) or die $!;\n \t\t}\n \t\tprint $sm \"$header\\n$message\";\n \t\tclose $sm or die $!;\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 65b3035371..31d25b32b5 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -2148,6 +2148,18 @@ test_expect_success $PREREQ 'leading and trailing whitespaces are removed' '\n \ttest_cmp expected-list actual-list\n '\n \n+test_expect_success $PREREQ 'test using a command for smtpServer with !' '\n+\tclean_fake_sendmail &&\n+\tPATH=\"$(pwd):$PATH\" \\\n+\tgit send-email \\\n+\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t--to=nobody@example.com \\\n+\t\t--smtp-server=\"!fake.sendmail\" \\\n+\t\tHEAD~2 2>errors &&\n+\ttest_path_is_file commandline1 &&\n+\ttest_path_is_file commandline2\n+'\n+\n test_expect_success $PREREQ 'invoke hook' '\n \tmkdir -p .git/hooks &&\n \n-- \n2.31.1\n\n"},{"id":"424229","messageId":"YJsas0d4XPsYYpI7@camp.crustytoothpaste.net","threadId":"55664","inReplyTo":"20210511234935.65147-1-greg@gpanders.com","subject":"Re: [PATCH v5] git-send-email: use ! to indicate relative path to command","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2021-05-12T00:00:51Z","receivedAt":"2021-05-12T00:01:29Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2021-05-11 at 23:49:35, Gregory Anders wrote:\n> The sendemail.smtpServer configuration option and the '--smtp-server'\n> command line option can name a program to use by providing an absolute\n> path to the program. However, an absolute path is not always portable\n> and it is often preferable to simply specify a program name and have\n> 'git-send-email' find that program on $PATH.\n> \n> For example, if a user wishes to use msmtp to send emails, they might\n> be able to simply use\n> \n>     [sendemail]\n>             smtpServer = !msmtp\n> \n> instead of using the full path. This is particularly useful when a\n> common git config file is used across multiple systems where the\n> absolute path to a given program may differ.\n> \n> To that end, this patch allows both the configuration and command line\n> options to be prefixed with a '!' character to indicate that the\n> specified command should be found on $PATH, as if the user had entered\n> it directly on the command line.\n\nI think the idea of providing a way to invoke a sendmail-compatible mail\nserver is a good idea.\n\n> Signed-off-by: Gregory Anders <greg@gpanders.com>\n> ---\n> Diff from v4:\n> \n> * Update the test with suggestions from Jeff King (this should fix \n>   erroneous test failures caused by patch files being deleted by earlier \n>   tests)\n> * Reword the commit message with feedback from Jeff King and Junio \n>   Hamano\n> \n>  Documentation/git-send-email.txt | 13 +++++++------\n>  git-send-email.perl              |  7 +++++--\n>  t/t9001-send-email.sh            | 12 ++++++++++++\n>  3 files changed, 24 insertions(+), 8 deletions(-)\n> \n> diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\n> index 93708aefea..418e66c703 100644\n> --- a/Documentation/git-send-email.txt\n> +++ b/Documentation/git-send-email.txt\n> @@ -212,12 +212,13 @@ a password is obtained using 'git-credential'.\n>  --smtp-server=<host>::\n>  \tIf set, specifies the outgoing SMTP server to use (e.g.\n>  \t`smtp.example.com` or a raw IP address).  Alternatively it can\n> -\tspecify a full pathname of a sendmail-like program instead;\n> -\tthe program must support the `-i` option.  Default value can\n> -\tbe specified by the `sendemail.smtpServer` configuration\n> -\toption; the built-in default is to search for `sendmail` in\n> -\t`/usr/sbin`, `/usr/lib` and $PATH if such program is\n> -\tavailable, falling back to `localhost` otherwise.\n> +\tspecify a sendmail-like program instead, either by a full\n> +\tpath-name or by prefixing the program name with `!`.  The\n> +\tprogram must support the `-i` option.  Default value can be\n> +\tspecified by the `sendemail.smtpServer` configuration option;\n> +\tthe built-in default is to search for `sendmail` in `/usr/sbin`,\n> +\t`/usr/lib` and $PATH if such program is available, falling back\n> +\tto `localhost` otherwise.\n\nElsewhere we use the ! syntax we invoke the shell, and I would suggest\nthat we do the same here.  That means we'll get PATH functionality by\ndefault and we'll let people do a modicum of scripting if they like.\n-- \nbrian m. carlson (he/him or they/them)\nHouston, Texas, US\n"},{"id":"424235","messageId":"YJsi1jbtNFDRKXmq@coredump.intra.peff.net","threadId":"55664","inReplyTo":"YJsas0d4XPsYYpI7@camp.crustytoothpaste.net","subject":"Re: [PATCH v5] git-send-email: use ! to indicate relative path to command","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-05-12T00:35:34Z","receivedAt":"2021-05-12T00:35:36Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, May 12, 2021 at 12:00:51AM +0000, brian m. carlson wrote:\n\n> > +\tspecify a sendmail-like program instead, either by a full\n> > +\tpath-name or by prefixing the program name with `!`.  The\n> > +\tprogram must support the `-i` option.  Default value can be\n> > +\tspecified by the `sendemail.smtpServer` configuration option;\n> > +\tthe built-in default is to search for `sendmail` in `/usr/sbin`,\n> > +\t`/usr/lib` and $PATH if such program is available, falling back\n> > +\tto `localhost` otherwise.\n> \n> Elsewhere we use the ! syntax we invoke the shell, and I would suggest\n> that we do the same here.  That means we'll get PATH functionality by\n> default and we'll let people do a modicum of scripting if they like.\n\nThanks for bringing that up. I agree it makes things more consistent\nwith other uses of \"!\", and certainly it's more flexible. It does\nintroduce an inconsistency with the absolute-path form, as I mentioned\nin https://lore.kernel.org/git/YJsiKDNbKclFU00b@coredump.intra.peff.net/.\n\nI don't know if that's a show-stopper or not. Certainly the\ndocumentation can explain the difference, but it's nice to keep the\nrules as simple as possible.\n\n(My gut feeling is that consistency with other \"!\" places is more\nimportant than consistency with the absolute-path form).\n\n-Peff\n"},{"id":"424238","messageId":"YJslRhzOmSwD7V2E@gpanders.com","threadId":"55664","inReplyTo":"YJsi1jbtNFDRKXmq@coredump.intra.peff.net","subject":"Re: [PATCH v5] git-send-email: use ! to indicate relative path to command","fromName":"Gregory Anders","fromEmail":"greg@gpanders.com","sentAt":"2021-05-12T00:45:58Z","receivedAt":"2021-05-12T00:46:06Z","isPatch":true,"sender":{"key":"greg@gpanders.com","avatar":"https://avatars.githubusercontent.com/u/8965202?v=4"},"body":"On Tue, 11 May 2021 20:35 -0400, Jeff King wrote:\n>On Wed, May 12, 2021 at 12:00:51AM +0000, brian m. carlson wrote:\n>\n>> > +\tspecify a sendmail-like program instead, either by a full\n>> > +\tpath-name or by prefixing the program name with `!`.  The\n>> > +\tprogram must support the `-i` option.  Default value can be\n>> > +\tspecified by the `sendemail.smtpServer` configuration option;\n>> > +\tthe built-in default is to search for `sendmail` in `/usr/sbin`,\n>> > +\t`/usr/lib` and $PATH if such program is available, falling back\n>> > +\tto `localhost` otherwise.\n>>\n>> Elsewhere we use the ! syntax we invoke the shell, and I would suggest\n>> that we do the same here.  That means we'll get PATH functionality by\n>> default and we'll let people do a modicum of scripting if they like.\n>\n>Thanks for bringing that up. I agree it makes things more consistent\n>with other uses of \"!\", and certainly it's more flexible. It does\n>introduce an inconsistency with the absolute-path form, as I mentioned\n>in https://lore.kernel.org/git/YJsiKDNbKclFU00b@coredump.intra.peff.net/.\n>\n>I don't know if that's a show-stopper or not. Certainly the\n>documentation can explain the difference, but it's nice to keep the\n>rules as simple as possible.\n>\n>(My gut feeling is that consistency with other \"!\" places is more\n>important than consistency with the absolute-path form).\n>\n>-Peff\n\nWe already have sendemail.smtpServerOption to add options:\n\n     [sendemail]\n             smtpServer = !msmtp\n             smtpServerOption = -f\n             smtpServerOption = greg@gpanders.com\n\nI agree that it's not the prettiest and it's a little annoying to have \nto specify the option multiple times, but I thought it worth mentioning \nbefore considering another way to do the same thing.\n\nI also am curious what other's thoughts are on Felipe's suggestion to \nadd a sendemail.program option, which would altogether remove the need \nto further overload sendemail.smtpServer: \nhttps://lore.kernel.org/git/609b0017a323b_6064920888@natae.notmuch/\n\nIMO if we want to add the capability to run an arbitrary shell command \nas the smtpServer, this makes more sense to add as a dedicated \nsendemail.program option that has that functionality baked right in:\n\n     [sendemail]\n             program = \"msmtp -f greg@gpanders.com\"\n"},{"id":"424239","messageId":"YJslulEQFvPkyo/R@coredump.intra.peff.net","threadId":"55664","inReplyTo":"YJsDAnHcnro6Gfk4@gpanders.com","subject":"Re: [PATCH v3] git-send-email: use ! to indicate relative path to command","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-05-12T00:47:54Z","receivedAt":"2021-05-12T00:47:57Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, May 11, 2021 at 04:19:46PM -0600, Gregory Anders wrote:\n\n> On Tue, 11 May 2021 17:07 -0500, Felipe Contreras wrote:\n> > It would be much better to have sendemail.program, and then we wouldn't\n> > need to deal with these workarounds.\n> \n> Frankly I agree. Should I modify my patch to add this new option instead of\n> modifying the behavior of smtpServer? Obviously the smtpServer option would\n> need to preserve its current behavior for backward compatibility.\n\nYeah, that was mentioned in the thread I linked earlier. I think it\nwould be a fine solution, too. It would probably make sense for it to\nuse the shell, as suggested elsewhere, and to call it \"smtp-command\" for\nconsistency with other parts of Git (I'm thinking particularly of\nGIT_SSH versus GIT_SSH_COMMAND, where the latter was introduced to fix\nthe defect that the former could not provide any arguments).\n\n-Peff\n"},{"id":"424240","messageId":"YJsmNoLu9B0SgWz7@coredump.intra.peff.net","threadId":"55664","inReplyTo":"YJslRhzOmSwD7V2E@gpanders.com","subject":"Re: [PATCH v5] git-send-email: use ! to indicate relative path to command","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-05-12T00:49:58Z","receivedAt":"2021-05-12T00:50:01Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, May 11, 2021 at 06:45:58PM -0600, Gregory Anders wrote:\n\n> > > Elsewhere we use the ! syntax we invoke the shell, and I would suggest\n> > > that we do the same here.  That means we'll get PATH functionality by\n> > > default and we'll let people do a modicum of scripting if they like.\n> > \n> > Thanks for bringing that up. I agree it makes things more consistent\n> > with other uses of \"!\", and certainly it's more flexible. It does\n> > introduce an inconsistency with the absolute-path form, as I mentioned\n> > in https://lore.kernel.org/git/YJsiKDNbKclFU00b@coredump.intra.peff.net/.\n> > \n> > I don't know if that's a show-stopper or not. Certainly the\n> > documentation can explain the difference, but it's nice to keep the\n> > rules as simple as possible.\n> > \n> > (My gut feeling is that consistency with other \"!\" places is more\n> > important than consistency with the absolute-path form).\n> > \n> > -Peff\n> \n> We already have sendemail.smtpServerOption to add options:\n> \n>     [sendemail]\n>             smtpServer = !msmtp\n>             smtpServerOption = -f\n>             smtpServerOption = greg@gpanders.com\n> \n> I agree that it's not the prettiest and it's a little annoying to have to\n> specify the option multiple times, but I thought it worth mentioning before\n> considering another way to do the same thing.\n\nThanks for bringing that up. I agree that does give back some of the\nflexibility, but it is inconsistent with most other parts of Git.\n\n> I also am curious what other's thoughts are on Felipe's suggestion to add a\n> sendemail.program option, which would altogether remove the need to further\n> overload sendemail.smtpServer:\n> https://lore.kernel.org/git/609b0017a323b_6064920888@natae.notmuch/\n> \n> IMO if we want to add the capability to run an arbitrary shell command as\n> the smtpServer, this makes more sense to add as a dedicated\n> sendemail.program option that has that functionality baked right in:\n> \n>     [sendemail]\n>             program = \"msmtp -f greg@gpanders.com\"\n\nOur mails just crossed, but yeah, I think that would be a fine\ndirection.\n\n-Peff\n"},{"id":"424241","messageId":"YJsmeOjxd5VIbjoM@camp.crustytoothpaste.net","threadId":"55664","inReplyTo":"YJsi1jbtNFDRKXmq@coredump.intra.peff.net","subject":"Re: [PATCH v5] git-send-email: use ! to indicate relative path to command","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2021-05-12T00:51:04Z","receivedAt":"2021-05-12T00:51:12Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2021-05-12 at 00:35:34, Jeff King wrote:\n> On Wed, May 12, 2021 at 12:00:51AM +0000, brian m. carlson wrote:\n> \n> > > +\tspecify a sendmail-like program instead, either by a full\n> > > +\tpath-name or by prefixing the program name with `!`.  The\n> > > +\tprogram must support the `-i` option.  Default value can be\n> > > +\tspecified by the `sendemail.smtpServer` configuration option;\n> > > +\tthe built-in default is to search for `sendmail` in `/usr/sbin`,\n> > > +\t`/usr/lib` and $PATH if such program is available, falling back\n> > > +\tto `localhost` otherwise.\n> > \n> > Elsewhere we use the ! syntax we invoke the shell, and I would suggest\n> > that we do the same here.  That means we'll get PATH functionality by\n> > default and we'll let people do a modicum of scripting if they like.\n> \n> Thanks for bringing that up. I agree it makes things more consistent\n> with other uses of \"!\", and certainly it's more flexible. It does\n> introduce an inconsistency with the absolute-path form, as I mentioned\n> in https://lore.kernel.org/git/YJsiKDNbKclFU00b@coredump.intra.peff.net/.\n> \n> I don't know if that's a show-stopper or not. Certainly the\n> documentation can explain the difference, but it's nice to keep the\n> rules as simple as possible.\n\nI think the minor incompatibility here is okay.  It would have been\nnicer to be able to avoid it, but hindsight is always 20/20.\n\n> (My gut feeling is that consistency with other \"!\" places is more\n> important than consistency with the absolute-path form).\n\nYeah, I think the shell here can be very useful, because it lets you\nconfigure something once in .gitconfig and handle system\nincompatibilities (a purely hypothetical example):\n\n  !f() { if [ \"$(uname -s)\" = Darwin ]; then sendmail \"$@\"; else postfix \"$@\"; fi; };f\n\nPeople use this functionality all the time in other places: credential\nhelpers, editors (use a fancy graphical editor if supported, otherwise\nVim), and various other places we allow this syntax.\n-- \nbrian m. carlson (he/him or they/them)\nHouston, Texas, US\n"},{"id":"424243","messageId":"609b2aa26aa5b_678ff20893@natae.notmuch","threadId":"55664","inReplyTo":"YJslulEQFvPkyo/R@coredump.intra.peff.net","subject":"Re: [PATCH v3] git-send-email: use ! to indicate relative path to command","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-12T01:08:50Z","receivedAt":"2021-05-12T01:08:55Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Jeff King wrote:\n> On Tue, May 11, 2021 at 04:19:46PM -0600, Gregory Anders wrote:\n> > Frankly I agree. Should I modify my patch to add this new option instead of\n> > modifying the behavior of smtpServer? Obviously the smtpServer option would\n> > need to preserve its current behavior for backward compatibility.\n> \n> Yeah, that was mentioned in the thread I linked earlier. I think it\n> would be a fine solution, too. It would probably make sense for it to\n> use the shell, as suggested elsewhere, and to call it \"smtp-command\" for\n> consistency with other parts of Git (I'm thinking particularly of\n> GIT_SSH versus GIT_SSH_COMMAND, where the latter was introduced to fix\n> the defect that the former could not provide any arguments).\n\nBut it would be \"smtpserver-command\", and I don't think that the best\nnaming, because it doesn't necessarily have anything to do with SMTP, or\na server.\n\nI think simply sendemail.command is perfectly fine.\n\n-- \nFelipe Contreras\n"},{"id":"424245","messageId":"YJsuYAc+NniTWBc8@coredump.intra.peff.net","threadId":"55664","inReplyTo":"609b2aa26aa5b_678ff20893@natae.notmuch","subject":"Re: [PATCH v3] git-send-email: use ! to indicate relative path to command","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-05-12T01:24:48Z","receivedAt":"2021-05-12T01:27:27Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, May 11, 2021 at 08:08:50PM -0500, Felipe Contreras wrote:\n\n> > Yeah, that was mentioned in the thread I linked earlier. I think it\n> > would be a fine solution, too. It would probably make sense for it to\n> > use the shell, as suggested elsewhere, and to call it \"smtp-command\" for\n> > consistency with other parts of Git (I'm thinking particularly of\n> > GIT_SSH versus GIT_SSH_COMMAND, where the latter was introduced to fix\n> > the defect that the former could not provide any arguments).\n> \n> But it would be \"smtpserver-command\", and I don't think that the best\n> naming, because it doesn't necessarily have anything to do with SMTP, or\n> a server.\n> \n> I think simply sendemail.command is perfectly fine.\n\nAren't there many other \"commands\" run by send-email, like --to-cmd and\n--cc-cmd? It probably should indicate somehow that it is the command for\nsending mail. I agree it does not have to say \"SMTP\". If it is meant to\nbe compatible with sendmail, then maybe \"sendemail.sendmailCommand\" and\n\"--sendmail-cmd\" would work.\n\n-Peff\n"},{"id":"424248","messageId":"609b34d66a0bc_678ff2083@natae.notmuch","threadId":"55664","inReplyTo":"YJsuYAc+NniTWBc8@coredump.intra.peff.net","subject":"Re: [PATCH v3] git-send-email: use ! to indicate relative path to command","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-12T01:52:22Z","receivedAt":"2021-05-12T01:52:27Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Jeff King wrote:\n> On Tue, May 11, 2021 at 08:08:50PM -0500, Felipe Contreras wrote:\n> \n> > > Yeah, that was mentioned in the thread I linked earlier. I think it\n> > > would be a fine solution, too. It would probably make sense for it to\n> > > use the shell, as suggested elsewhere, and to call it \"smtp-command\" for\n> > > consistency with other parts of Git (I'm thinking particularly of\n> > > GIT_SSH versus GIT_SSH_COMMAND, where the latter was introduced to fix\n> > > the defect that the former could not provide any arguments).\n> > \n> > But it would be \"smtpserver-command\", and I don't think that the best\n> > naming, because it doesn't necessarily have anything to do with SMTP, or\n> > a server.\n> > \n> > I think simply sendemail.command is perfectly fine.\n> \n> Aren't there many other \"commands\" run by send-email, like --to-cmd and\n> --cc-cmd? It probably should indicate somehow that it is the command for\n> sending mail. I agree it does not have to say \"SMTP\". If it is meant to\n> be compatible with sendmail, then maybe \"sendemail.sendmailCommand\" and\n> \"--sendmail-cmd\" would work.\n\nYes, although I find sendemail.sendmailCommand awfully redundant.\nI would prefer sendemail.mainCommand, but to me sendemail.command\nimplies it's the main command as opposed to all ther other commands.\n\nJust like there's many presidents in USA (of companies, organizations,\nand student unions), but when you say \"the president of USA\" it's\nunderstood which president you are talking about.\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"424249","messageId":"YJs2RceLliGHI5TX@gpanders.com","threadId":"55664","inReplyTo":"609b34d66a0bc_678ff2083@natae.notmuch","subject":"Re: [PATCH v3] git-send-email: use ! to indicate relative path to command","fromName":"Gregory Anders","fromEmail":"greg@gpanders.com","sentAt":"2021-05-12T01:58:29Z","receivedAt":"2021-05-12T01:58:39Z","isPatch":true,"sender":{"key":"greg@gpanders.com","avatar":"https://avatars.githubusercontent.com/u/8965202?v=4"},"body":"On Tue, 11 May 2021 20:52 -0500, Felipe Contreras wrote:\n>Jeff King wrote:\n>> On Tue, May 11, 2021 at 08:08:50PM -0500, Felipe Contreras wrote:\n>>\n>> > > Yeah, that was mentioned in the thread I linked earlier. I think it\n>> > > would be a fine solution, too. It would probably make sense for it to\n>> > > use the shell, as suggested elsewhere, and to call it \"smtp-command\" for\n>> > > consistency with other parts of Git (I'm thinking particularly of\n>> > > GIT_SSH versus GIT_SSH_COMMAND, where the latter was introduced to fix\n>> > > the defect that the former could not provide any arguments).\n>> >\n>> > But it would be \"smtpserver-command\", and I don't think that the best\n>> > naming, because it doesn't necessarily have anything to do with SMTP, or\n>> > a server.\n>> >\n>> > I think simply sendemail.command is perfectly fine.\n>>\n>> Aren't there many other \"commands\" run by send-email, like --to-cmd and\n>> --cc-cmd? It probably should indicate somehow that it is the command for\n>> sending mail. I agree it does not have to say \"SMTP\". If it is meant to\n>> be compatible with sendmail, then maybe \"sendemail.sendmailCommand\" and\n>> \"--sendmail-cmd\" would work.\n>\n>Yes, although I find sendemail.sendmailCommand awfully redundant.\n>I would prefer sendemail.mainCommand, but to me sendemail.command\n>implies it's the main command as opposed to all ther other commands.\n>\n>Just like there's many presidents in USA (of companies, organizations,\n>and student unions), but when you say \"the president of USA\" it's\n>understood which president you are talking about.\n>\n>Cheers.\n>\n>-- \n>Felipe Contreras\n\nI agree with Jeff here. While I also find sendemail.sendmailCommand \nredundant, it makes more sense when used as a command line option:\n\n     git send-email --sendmail-cmd <cmd>\n\nConversely, `--command` is more ambiguous and less clear. Explicitly \nusing `sendmailCommand` makes it clear that the user is specifying a \ncommand that is compatible with the `sendmail` program.\n"},{"id":"424269","messageId":"xmqqpmxwhbnv.fsf@gitster.g","threadId":"55664","inReplyTo":"YJslRhzOmSwD7V2E@gpanders.com","subject":"Re: [PATCH v5] git-send-email: use ! to indicate relative path to command","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-05-12T03:29:56Z","receivedAt":"2021-05-12T03:30:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Gregory Anders <greg@gpanders.com> writes:\n\n> We already have sendemail.smtpServerOption to add options:\n>\n>     [sendemail]\n>             smtpServer = !msmtp\n>             smtpServerOption = -f\n>             smtpServerOption = greg@gpanders.com\n>\n> I agree that it's not the prettiest and it's a little annoying to have\n> to specify the option multiple times, but I thought it worth\n> mentioning before considering another way to do the same thing.\n\nWell, then can't we just scrap this whole topic, like\n\n    [sendemail]\n\tsmtpServer = /usr/bin/env\n\tsmtpServerOption = msmtp\n\nwould already work without adding '!' support ;-)\n\nsendemail.command is also fine; make it invoke the command line via\nthe shell and we can gradually depreate the \"server that is an\nabsolute path is the name of a program to talk to the server\".\n\n"},{"id":"424275","messageId":"609b56c84a65_678ff208f1@natae.notmuch","threadId":"55664","inReplyTo":"YJs2RceLliGHI5TX@gpanders.com","subject":"Re: [PATCH v3] git-send-email: use ! to indicate relative path to command","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-12T04:17:12Z","receivedAt":"2021-05-12T04:17:19Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Gregory Anders wrote:\n> On Tue, 11 May 2021 20:52 -0500, Felipe Contreras wrote:\n> >> > I think simply sendemail.command is perfectly fine.\n> >>\n> >> Aren't there many other \"commands\" run by send-email, like --to-cmd and\n> >> --cc-cmd? It probably should indicate somehow that it is the command for\n> >> sending mail. I agree it does not have to say \"SMTP\". If it is meant to\n> >> be compatible with sendmail, then maybe \"sendemail.sendmailCommand\" and\n> >> \"--sendmail-cmd\" would work.\n> >\n> >Yes, although I find sendemail.sendmailCommand awfully redundant.\n> >I would prefer sendemail.mainCommand, but to me sendemail.command\n> >implies it's the main command as opposed to all ther other commands.\n> >\n> >Just like there's many presidents in USA (of companies, organizations,\n> >and student unions), but when you say \"the president of USA\" it's\n> >understood which president you are talking about.\n> \n> I agree with Jeff here. While I also find sendemail.sendmailCommand \n> redundant, it makes more sense when used as a command line option:\n> \n>      git send-email --sendmail-cmd <cmd>\n> \n> Conversely, `--command` is more ambiguous and less clear. Explicitly \n> using `sendmailCommand` makes it clear that the user is specifying a \n> command that is compatible with the `sendmail` program.\n\nSo would `git send-email --sendmail <cmd>`.\n\nTo make it clear, I think the options are:\n\n 1. `git send-email --sendmail <cmd>`: `sendemail.sendmail`\n 2. `git send-email --command <cmd>`: `sendemail.command`\n\nI lean towards #2 since I think most people do a configuration and\nforget about it it; they will rarely use the --command argument.\n\nWhat I'm really against is:\n\n  sendemail.sendmail-command.sendmail = sendmail\n\nCheers.\n\n-- \nFelipe Contreras\n"}]}