threaded patch series
Subsystems (2)
Hi guys,
What is needed to get a patch series to be threaded? I had never sent a series of patches before and wrongly thought it would automatically be threaded. In the recent patch series I sent, I used "git send-email" in a script that listed the commands with cc's and such. What should I have done?
Thanks,
mfm
--
GPG-Key: 9AFE00EA
Quoted 4 lines · matt mooney
What is needed to get a patch series to be threaded?
In the recent patch series I sent, I used "git send-email" in a script that listed the commands with cc's and such. What should I have done?
It depends on what version of git you're using.
I think 1.7 changed the defaults.
I use:
$ git format-patch --thread=shallow --cover-letter ... then $ git send-email --nothread --no-chain-reply-to --suppress-cc=self ...
I also sometimes use an option to send-email that generates the cc's using a shell script with scripts/get_maintainer.pl
$ git send-email --nothread --no-chain-reply-to --suppress-cc=self \
--cc-cmd=<file> ...Where <file> could be:
$ cat scripts/send-email-listed-MAINTAINERS-only
#!/bin/bash
if [[ $(basename $1) =~ ^0000- ]] ; then
./scripts/get_maintainer.pl --nogit $(dirname $1)/*
else
./scripts/get_maintainer.pl --nogit $1
fiIf the cc list is very long, vger might not accept the cover letter 0000-<foo> email, so adding --nom like this could be better:
$ cat scripts/send-email-listed-MAINTAINERS-only
#!/bin/bash
if [[ $(basename $1) =~ ^0000- ]] ; then
./scripts/get_maintainer.pl --nogit --nom $(dirname $1)/*
else
./scripts/get_maintainer.pl --nogit $1
fiI made some changes to git-send-email to get it to send mail to different people, ie a different set of addresses for each patch. Is that now possible with the standard version? If not I can submit a patch with my changes at some point.
julia
Quoted 48 lines · Joe Perches
Quoted 4 lines · matt mooney
What is needed to get a patch series to be threaded?
In the recent patch series I sent, I used "git send-email" in a script that listed the commands with cc's and such. What should I have done?It depends on what version of git you're using.
I think 1.7 changed the defaults.I use:
$ git format-patch --thread=shallow --cover-letter ... then $ git send-email --nothread --no-chain-reply-to --suppress-cc=self ...I also sometimes use an option to send-email that generates the cc's using a shell script with
scripts/get_maintainer.pl$ git send-email --nothread --no-chain-reply-to --suppress-cc=self \ --cc-cmd=<file> ...Where <file> could be:
$ cat scripts/send-email-listed-MAINTAINERS-only #!/bin/bash if [[ $(basename $1) =~ ^0000- ]] ; then ./scripts/get_maintainer.pl --nogit $(dirname $1)/* else ./scripts/get_maintainer.pl --nogit $1 fiIf the cc list is very long, vger might not accept the cover letter 0000-<foo> email, so adding --nom like this could be better:
$ cat scripts/send-email-listed-MAINTAINERS-only #!/bin/bash if [[ $(basename $1) =~ ^0000- ]] ; then ./scripts/get_maintainer.pl --nogit --nom $(dirname $1)/* else ./scripts/get_maintainer.pl --nogit $1 fi--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 4 lines · Julia Lawall
I made some changes to git-send-email to get it to send mail to different people, ie a different set of addresses for each patch. Is that now possible with the standard version? If not I can submit a patch with my changes at some point.
I believe it's not currently possible to have
different "to:" addresses in a git send-email
patch series and that could be a useful patch
to submit.
Quoted 4 lines · Julia Lawall
I made some changes to git-send-email to get it to send mail to different people, ie a different set of addresses for each patch. Is that now possible with the standard version? If not I can submit a patch with my changes at some point.
I use git-send-email --cc-cmd=script_to_form_cc_list.
Signature · 1 line
Vasiliy
Quoted 7 lines · Vasiliy Kulikov
Quoted 4 lines · Julia Lawall
I made some changes to git-send-email to get it to send mail to different people, ie a different set of addresses for each patch. Is that now possible with the standard version? If not I can submit a patch with my changes at some point.
I use git-send-email --cc-cmd=script_to_form_cc_list.
I mean this:
for f in *.patch; do
CMD="script_to_form_cc_list $f"
git-send-email --cc-cmd="$CMD" ... "$f"done
Signature · 1 line
Vasiliy
Quoted 7 lines · Vasiliy Kulikov
Quoted 6 lines · Vasiliy Kulikov
Quoted 4 lines · Julia Lawall
I made some changes to git-send-email to get it to send mail to different people, ie a different set of addresses for each patch. Is that now possible with the standard version? If not I can submit a patch with my changes at some point.
I use git-send-email --cc-cmd=script_to_form_cc_list.
I believe that Julia means some mechanism to vary the "to" addresses for each patch, ie: some "--to-cmd=cmd".
Quoted 5 lines
I mean this:
for f in *.patch; doCMD="script_to_form_cc_list $f" git-send-email --cc-cmd="$CMD" ... "$f"done
You could also do that with a single line as the target cc-cmd receives each $f as argument.
git send-email --cc-cmd=script_to_form_cc_list ... *.patch
Quoted 11 lines · Joe Perches
Quoted 7 lines · Vasiliy Kulikov
Quoted 6 lines · Vasiliy Kulikov
Quoted 4 lines · Julia Lawall
I made some changes to git-send-email to get it to send mail to different people, ie a different set of addresses for each patch. Is that now possible with the standard version? If not I can submit a patch with my changes at some point.
I use git-send-email --cc-cmd=script_to_form_cc_list.
I believe that Julia means some mechanism to vary the "to" addresses for each patch, ie: some "--to-cmd=cmd".
Yes, sort of. I took the strategy of precomputing the To addresses, so I just have a collection of files that have different To and Cc addresses. But a --to-cmd option seems like a good idea too.
julia
Quoted 13 lines
Quoted 5 lines
I mean this:
for f in *.patch; doCMD="script_to_form_cc_list $f" git-send-email --cc-cmd="$CMD" ... "$f"done
You could also do that with a single line as the target cc-cmd receives each $f as argument.
git send-email --cc-cmd=script_to_form_cc_list ... *.patch
RFC PATCH 1/1 sit-send-email.pl: Add --to-cmd
Quoted 8 lines · Julia Lawall
Quoted 7 lines · Joe Perches
Quoted 6 lines · Vasiliy Kulikov
Quoted 5 lines · Vasiliy Kulikov
Quoted 4 lines · Julia Lawall
I made some changes to git-send-email to get it to send mail to different people, ie a different set of addresses for each patch. Is that now possible with the standard version? If not I can submit a patch with my changes at some point.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
I use git-send-email --cc-cmd=script_to_form_cc_list.
I believe that Julia means some mechanism to vary the "to" addresses for each patch, ie: some "--to-cmd=cmd".
Yes, sort of. I took the strategy of precomputing the To addresses, so I just have a collection of files that have different To and Cc addresses. But a --to-cmd option seems like a good idea too.
Perhaps something like this?
Lightly tested only.
I know there's a test harness in git, but
I don't know how to wire up the new options.
--- git-send-email.perl | 25 +++++++++++++++++++++++-- 1 files changed, 23 insertions(+), 2 deletions(-)
git-send-email.perl +23 -2
@@ -70,6 +70,7 @@ git send-email [options] <file | directory | rev-list options > Automating: --identity <str> * Use the sendemail.<id> options. + --to-cmd <str> * Email To: via `<str> \$patch_path` --cc-cmd <str> * Email Cc: via `<str> \$patch_path` --suppress-cc <str> * author, self, sob, cc, cccmd, body, bodycc, all. --[no-]signed-off-by-cc * Send to Signed-off-by: addresses. Default on.
@@ -187,7 +188,8 @@ sub do_edit { } # Variables with corresponding config settings -my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd); +my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc); +my ($to_cmd, $cc_cmd); my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption); my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts, $smtp_domain); my ($validate, $confirm);
@@ -214,6 +216,7 @@ my %config_settings = ( "smtppass" => \$smtp_authpass, "smtpdomain" => \$smtp_domain, "to" => \@to, + "tocmd" => \$to_cmd, "cc" => \@initial_cc, "cccmd" => \$cc_cmd, "aliasfiletype" => \$aliasfiletype,
@@ -272,6 +275,7 @@ my $rc = GetOptions("sender|from=s" => \$sender, "in-reply-to=s" => \$initial_reply_to, "subject=s" => \$initial_subject, "to=s" => \@to, + "to-cmd=s" => \$to_cmd, "no-to" => \$no_to, "cc=s" => \@initial_cc, "no-cc" => \$no_cc,
@@ -711,7 +715,7 @@ if (!defined $sender) { $prompting++; } -if (!@to) { +if (!@to && $to_cmd eq "") { my $to = ask("Who should the emails be sent to? "); push @to, parse_address_line($to) if defined $to; # sanitized/validated later $prompting++;
@@ -1238,6 +1242,23 @@ foreach my $t (@files) { } close F; + if (defined $to_cmd) { + open(F, "$to_cmd \Q$t\E |") + or die "(to-cmd) Could not execute '$to_cmd'"; + while(<F>) { + my $t = $_; + $t =~ s/^\s*//g; + $t =~ s/\n$//g; + next if ($t eq $sender and $suppress_from); + push @to, parse_address_line($t) + if defined $t; # sanitized/validated later + printf("(to-cmd) Adding To: %s from: '%s'\n", + $t, $to_cmd) unless $quiet; + } + close F + or die "(to-cmd) failed to close pipe to '$to_cmd'"; + } + if (defined $cc_cmd && !$suppress_cc{'cccmd'}) { open(F, "$cc_cmd \Q$t\E |") or die "(cc-cmd) Could not execute '$cc_cmd'";
Re: [RFC PATCH] sit-send-email.pl: Add --to-cmd
Quoted 16 lines · Joe Perches
Quoted 8 lines · Julia Lawall
Quoted 7 lines · Joe Perches
Quoted 6 lines · Vasiliy Kulikov
Quoted 5 lines · Vasiliy Kulikov
Quoted 4 lines · Julia Lawall
I made some changes to git-send-email to get it to send mail to different people, ie a different set of addresses for each patch. Is that now possible with the standard version? If not I can submit a patch with my changes at some point.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
I use git-send-email --cc-cmd=script_to_form_cc_list.
I believe that Julia means some mechanism to vary the "to" addresses for each patch, ie: some "--to-cmd=cmd".
Yes, sort of. I took the strategy of precomputing the To addresses, so I just have a collection of files that have different To and Cc addresses. But a --to-cmd option seems like a good idea too.
Quoted 6 lines
Perhaps something like this?
Lightly tested only.
I know there's a test harness in git, but
I don't know how to wire up the new options.
You'd add the tests to t9001-send-email.sh and --tocmd out to some program you create. Is there anything in particular you need help with?
Quoted 44 lines
Signed-off-by Joe Perches <[email protected]>---
git-send-email.perl | 25 +++++++++++++++++++++++--1 files changed, 23 insertions(+), 2 deletions(-)git-send-email.perl +0
-0@@ -70,6 +70,7 @@ git send-email [options] <file | directory | rev-list options >Automating:
--identity <str> * Use the sendemail.<id> options.
+ --to-cmd <str> * Email To: via<str> \$patch_path--cc-cmd <str> * Email Cc: via<str> \$patch_path--suppress-cc <str> * author, self, sob, cc, cccmd, body, bodycc, all. --[no-]signed-off-by-cc * Send to Signed-off-by: addresses. Default on.git-send-email.perl +4
-1@@ -187,7 +188,8 @@ sub do_edit { } # Variables with corresponding config settings -my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd); +my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc); +my ($to_cmd, $cc_cmd); my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption); my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts, $smtp_domain); my ($validate, $confirm);@@ -214,6 +216,7 @@ my %config_settings = ( "smtppass" => \$smtp_authpass, "smtpdomain" => \$smtp_domain, "to" => \@to, + "tocmd" => \$to_cmd, "cc" => \@initial_cc, "cccmd" => \$cc_cmd, "aliasfiletype" => \$aliasfiletype,@@ -272,6 +275,7 @@ my $rc = GetOptions("sender|from=s" => \$sender, "in-reply-to=s" => \$initial_reply_to, "subject=s" => \$initial_subject, "to=s" => \@to, + "to-cmd=s" => \$to_cmd, "no-to" => \$no_to, "cc=s" => \@initial_cc, "no-cc" => \$no_cc,
git-send-email.perl if (!defined $sender) { · line 718
Quoted 5 lines
git-send-email.perl +1
-1@@ -711,7 +715,7 @@ if (!defined $sender) { $prompting++; } -if (!@to) { +if (!@to && $to_cmd eq "") {
Why compare $to_cmd to "" instead of checking definedness?
git-send-email.perl foreach my $t (@files) { · line 1246
Quoted 9 lines
git-send-email.perl +0
-0my $to = ask("Who should the emails be sent to? ");push @to,
parse_address_line($to)if defined $to; # sanitized/validated later $prompting++;git-send-email.perl +2
-0@@ -1238,6 +1242,23 @@ foreach my $t (@files) { } close F; + if (defined $to_cmd) { + open(F, "$to_cmd \Q$t\E |")
quotemeta() is for escaping regexes, not shell syntax. You probably want IPC::Open2 or PC::Open3's functions which'll escape arguments for you.
Also "open my $f" is better, but I see the existing code uses glob filehandles (urghl).
git-send-email.perl foreach my $t (@files) { · line 1251
Quoted 5 lines
git-send-email.perl +5
-0+ or die "(to-cmd) Could not execute '$to_cmd'"; + while(<F>) { + my $t = $_; + $t =~ s/^\s*//g; + $t =~ s/\n$//g;
Shouldn't this just be:
while (my $address = <$f>) {
chomp $address;
...I.e. do you need to strip whitespace from the beginning of the string?
git-send-email.perl foreach my $t (@files) { · line 1260
Quoted 9 lines
git-send-email.perl +9
-0+ next if ($t eq $sender and $suppress_from); + push @to, parse_address_line($t) + if defined $t; # sanitized/validated later + printf("(to-cmd) Adding To: %s from: '%s'\n", + $t, $to_cmd) unless $quiet; + } + close F + or die "(to-cmd) failed to close pipe to '$to_cmd'"; + }
close F could be skipped if we used lexical handes, but see urghl above.
Re: [RFC PATCH] sit-send-email.pl: Add --to-cmd
Quoted 6 lines · Ævar Arnfjörð Bjarmason
Quoted 2 lines · Joe Perches
I know there's a test harness in git, but
I don't know how to wire up the new options.You'd add the tests to
t9001-send-email.shand --tocmd out to some program you create. Is there anything in particular you need help with?
Just the doing. I was (am) being lazy.
Quoted 4 lines
git-send-email.perl if (!defined $sender) { · line 718
Quoted 2 lines
git-send-email.perl +1
-1-if (!@to) { +if (!@to && $to_cmd eq "") {Why compare $to_cmd to "" instead of checking definedness?
No real reason. Using define is the style used in the rest of the file and it should be changed.
Quoted 10 lines
git-send-email.perl foreach my $t (@files) { · line 1246
Quoted 6 lines
git-send-email.perl +2
-0@@ -1238,6 +1242,23 @@ foreach my $t (@files) { } close F; + if (defined $to_cmd) { + open(F, "$to_cmd \Q$t\E |")
quotemeta()is for escaping regexes, not shell syntax. You probably wantIPC::Open2or PC::Open3's functions which'll escape arguments for you.
I just copied the style from the equivalent cc_cmd section below, so if it's necessary, it should be changed there too.
Quoted 1 line
I.e. do you need to strip whitespace from the beginning of the string?
I think so.
Re: [RFC PATCH] sit-send-email.pl: Add --to-cmd
Quoted 29 lines · Joe Perches
Quoted 6 lines · Ævar Arnfjörð Bjarmason
Quoted 2 lines · Joe Perches
I know there's a test harness in git, but
I don't know how to wire up the new options.You'd add the tests to
t9001-send-email.shand --tocmd out to some program you create. Is there anything in particular you need help with?Just the doing. I was (am) being lazy.
Quoted 4 lines
git-send-email.perl if (!defined $sender) { · line 718
Quoted 2 lines
git-send-email.perl +1
-1-if (!@to) { +if (!@to && $to_cmd eq "") {Why compare $to_cmd to "" instead of checking definedness?
No real reason. Using define is the style used in the rest of the file and it should be changed.
Quoted 10 lines
git-send-email.perl foreach my $t (@files) { · line 1246
Quoted 6 lines
git-send-email.perl +2
-0@@ -1238,6 +1242,23 @@ foreach my $t (@files) { } close F; + if (defined $to_cmd) { + open(F, "$to_cmd \Q$t\E |")
quotemeta()is for escaping regexes, not shell syntax. You probably wantIPC::Open2or PC::Open3's functions which'll escape arguments for you.
Quoted 6 lines
I just copied the style from the equivalent
cc_cmdsection below, so if it's necessary, it should be changed there too.Quoted 1 line
I.e. do you need to strip whitespace from the beginning of the string?
I think so.
This all sounds reasonable, but I really need to go through git-send-email.perl and fix all these bugs at some point...
PATCH v2 1/1 git-send-email.perl: Add --to-cmd
Add the ability to use a command line --to-cmd=cmd to create the list of "To:" addresses.
--- Documentation/git-send-email.txt | 8 +++++++- git-send-email.perl | 25 +++++++++++++++++++++++-- t/t9001-send-email.sh | 18 ++++++++++++++++++ 3 files changed, 48 insertions(+), 3 deletions(-)
Documentation/git-send-email.txt +7 -1
@@ -97,7 +97,7 @@ See the CONFIGURATION section for 'sendemail.multiedit'. Specify the primary recipient of the emails generated. Generally, this will be the upstream maintainer of the project involved. Default is the value of the 'sendemail.to' configuration value; if that is unspecified, - this will be prompted for. + and --to-cmd is not specified, this will be prompted for. + The --to option must be repeated for each user you want on the to list.
@@ -177,6 +177,12 @@ user is prompted for a password while the input is masked for privacy. Automating ~~~~~~~~~~ +--to-cmd=<command>:: + Specify a command to execute once per patch file which + should generate patch file specific "To:" entries. + Output of this command must be single email address per line. + Default is the value of 'sendemail.tocmd' configuration value. + --cc-cmd=<command>:: Specify a command to execute once per patch file which should generate patch file specific "Cc:" entries.
git-send-email.perl +23 -2
@@ -70,6 +70,7 @@ git send-email [options] <file | directory | rev-list options > Automating: --identity <str> * Use the sendemail.<id> options. + --to-cmd <str> * Email To: via `<str> \$patch_path` --cc-cmd <str> * Email Cc: via `<str> \$patch_path` --suppress-cc <str> * author, self, sob, cc, cccmd, body, bodycc, all. --[no-]signed-off-by-cc * Send to Signed-off-by: addresses. Default on.
@@ -187,7 +188,8 @@ sub do_edit { } # Variables with corresponding config settings -my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd); +my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc); +my ($to_cmd, $cc_cmd); my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption); my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts, $smtp_domain); my ($validate, $confirm);
@@ -214,6 +216,7 @@ my %config_settings = ( "smtppass" => \$smtp_authpass, "smtpdomain" => \$smtp_domain, "to" => \@to, + "tocmd" => \$to_cmd, "cc" => \@initial_cc, "cccmd" => \$cc_cmd, "aliasfiletype" => \$aliasfiletype,
@@ -272,6 +275,7 @@ my $rc = GetOptions("sender|from=s" => \$sender, "in-reply-to=s" => \$initial_reply_to, "subject=s" => \$initial_subject, "to=s" => \@to, + "to-cmd=s" => \$to_cmd, "no-to" => \$no_to, "cc=s" => \@initial_cc, "no-cc" => \$no_cc,
@@ -711,7 +715,7 @@ if (!defined $sender) { $prompting++; } -if (!@to) { +if (!@to && !defined $to_cmd) { my $to = ask("Who should the emails be sent to? "); push @to, parse_address_line($to) if defined $to; # sanitized/validated later $prompting++;
@@ -1238,6 +1242,23 @@ foreach my $t (@files) { } close F; + if (defined $to_cmd) { + open(F, "$to_cmd \Q$t\E |") + or die "(to-cmd) Could not execute '$to_cmd'"; + while(<F>) { + my $t = $_; + $t =~ s/^\s*//g; + $t =~ s/\n$//g; + next if ($t eq $sender and $suppress_from); + push @to, parse_address_line($t) + if defined $t; # sanitized/validated later + printf("(to-cmd) Adding To: %s from: '%s'\n", + $t, $to_cmd) unless $quiet; + } + close F + or die "(to-cmd) failed to close pipe to '$to_cmd'"; + } + if (defined $cc_cmd && !$suppress_cc{'cccmd'}) { open(F, "$cc_cmd \Q$t\E |") or die "(cc-cmd) Could not execute '$cc_cmd'";
t/t9001-send-email.sh +18 -0
@@ -201,6 +201,24 @@ test_expect_success $PREREQ 'Prompting works' ' grep "^To: [email protected]\$" msgtxt1 ' +test_expect_success $PREREQ 'tocmd works' ' + clean_fake_sendmail && + cp $patches tocmd.patch && + echo [email protected] >>tocmd.patch && + { + echo "#!$SHELL_PATH" + echo sed -n -e s/^tocmd--//p \"\$1\" + } > tocmd-sed && + chmod +x tocmd-sed && + git send-email \ + --from="Example <[email protected]>" \ + --to-cmd=./tocmd-sed \ + --smtp-server="$(pwd)/fake.sendmail" \ + tocmd.patch \ + && + grep "^To: [email protected]" msgtxt1 +' + test_expect_success $PREREQ 'cccmd works' ' clean_fake_sendmail && cp $patches cccmd.patch &&
Re: [PATCH V2] git-send-email.perl: Add --to-cmd
Quoted 9 lines · Joe Perches
Add the ability to use a command line --to-cmd=cmd to create the list of "To:" addresses.
Signed-off-by Joe Perches <[email protected]>---
Documentation/git-send-email.txt | 8 +++++++- git-send-email.perl | 25 +++++++++++++++++++++++--t/t9001-send-email.sh| 18 ++++++++++++++++++3 files changed, 48 insertions(+), 3 deletions(-)
Looks reasonable to me. Nice work getting on this quickly ;)
-mfm
Signature · 5 lines
GPG-Key: 9AFE00EA -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH V2] git-send-email.perl: Add --to-cmd
In reply to Joe Perchesgit-send-email.perl foreach my $t (@files) { · line 1249
Quoted 5 lines · Joe Perches
git-send-email.perl +5
-0+ if (defined $to_cmd) { + open(F, "$to_cmd \Q$t\E |") + or die "(to-cmd) Could not execute '$to_cmd'"; + while(<F>) { + my $t = $_;
"my $t" masks another $t in the outer scope; technically not a bug, but questionable as a style.
git-send-email.perl foreach my $t (@files) { · line 1254
Quoted 5 lines
git-send-email.perl +5
-0+ $t =~ s/^\s*//g; + $t =~ s/\n$//g; + next if ($t eq $sender and $suppress_from); + push @to, parse_address_line($t) + if defined $t; # sanitized/validated later
This "if defined $t" makes my head hurt. Why?
* The "while (<F>)" loop wouldn't have given you an undef in $t in the first place;
* You would have got "Use of uninitialized value" warning at these two s/// statements if $t were undef; and
* Even if $t were undef, these two s/// statements would have made $t a defined, empty string.
git-send-email.perl foreach my $t (@files) { · line 1260
Quoted 6 lines
git-send-email.perl +6
-0+ printf("(to-cmd) Adding To: %s from: '%s'\n", + $t, $to_cmd) unless $quiet; + } + close F + or die "(to-cmd) failed to close pipe to '$to_cmd'"; + }
In any case, this whole codeblock obviously is a copy-and-paste from corresponding $cc_cmd codepath, and I wonder if you can refactor the original into a common helper function first and then use it to make the addition of this feature a smaller patch.
if (defined $cc_cmd) {
push @cc, recipients_cmd($cc_cmd, 'cc');
}
if (defined $to_cmd) {
push @to, recipients_cmd($to_cmd, 'to');
}If you did so, the first patch that refactors to create a helper function can address issues Ævar raised in the review to clean things up, no?
I notice that you use parse_address_line() while $cc_cmd codepath doesn't. I haven't studied other codepaths deeply, but my gut feeling is that the reason why the $cc_cmd codepath does not call parse_address_line() before pushing the result to @cc is _not_ because strings on @cc shouldn't be sanitized (the codepath to parse "Cc: " calls parse_address_line and pushes the result to @cc), but because the code is simply sloppy. So I suspect that it would be Ok for recipients_cmd to call parse_address_line unconditionally.
Hmm?
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH V2] git-send-email.perl: Add --to-cmd
Quoted 19 lines · Junio C Hamano
Quoted 5 lines · Joe Perches
+ if (defined $to_cmd) {
+open(F, "$to_cmd \Q$t\E |")
+ or die "(to-cmd) Could not execute '$to_cmd'";
+ while(<F>) {
+ my $t = $_;"my $t" masks another $t in the outer scope; technically not a bug, but questionable as a style.
Quoted 5 lines
+ $t =~ s/^\s*//g;
+ $t =~ s/\n$//g;
+ next if ($t eq $sender and $suppress_from);
+ push @to,parse_address_line($t)
+ if defined $t; # sanitized/validated laterThis "if defined $t" makes my head hurt. Why?
Quoted 8 lines
* The "while (<F>)" loop wouldn't have given you an undef in $t in the first place;
* You would have got "Use of uninitialized value" warning at these two s/// statements if $t were undef; and
* Even if $t were undef, these two s/// statements would have made $t a defined, empty string.
Well spotted. Also it *can't* be undef here by definition. Since $t is taken from the $_ value which comes from the <> operator. That just wraps readline(), which will exit the loop when it hit EOF (at which point readline() *would* return undef).
So this whole business of checking for the definedness of $t doesn't make any sense.
PATCH v3 1/1 git-send-email.perl: Add --to-cmd
In reply to Junio C HamanoAdd the ability to use a command line --to-cmd=cmd to create the list of "To:" addresses.
Used a shared routine for --cc-cmd and --to-cmd.
Did not use IPC::Open2, leaving that for Ævar if ever he decides to fix the other bugs he might find.
--- Documentation/git-send-email.txt | 8 +++++- git-send-email.perl | 51 +++++++++++++++++++++++++------------ t/t9001-send-email.sh | 18 +++++++++++++ 3 files changed, 59 insertions(+), 18 deletions(-)
Documentation/git-send-email.txt +7 -1
@@ -97,7 +97,7 @@ See the CONFIGURATION section for 'sendemail.multiedit'. Specify the primary recipient of the emails generated. Generally, this will be the upstream maintainer of the project involved. Default is the value of the 'sendemail.to' configuration value; if that is unspecified, - this will be prompted for. + and --to-cmd is not specified, this will be prompted for. + The --to option must be repeated for each user you want on the to list.
@@ -177,6 +177,12 @@ user is prompted for a password while the input is masked for privacy. Automating ~~~~~~~~~~ +--to-cmd=<command>:: + Specify a command to execute once per patch file which + should generate patch file specific "To:" entries. + Output of this command must be single email address per line. + Default is the value of 'sendemail.tocmd' configuration value. + --cc-cmd=<command>:: Specify a command to execute once per patch file which should generate patch file specific "Cc:" entries.
git-send-email.perl +34 -17
93 lines not on this page · raw message
t/t9001-send-email.sh +18 -0
@@ -201,6 +201,24 @@ test_expect_success $PREREQ 'Prompting works' ' grep "^To: [email protected]\$" msgtxt1 ' +test_expect_success $PREREQ 'tocmd works' ' + clean_fake_sendmail && + cp $patches tocmd.patch && + echo [email protected] >>tocmd.patch && + { + echo "#!$SHELL_PATH" + echo sed -n -e s/^tocmd--//p \"\$1\" + } > tocmd-sed && + chmod +x tocmd-sed && + git send-email \ + --from="Example <[email protected]>" \ + --to-cmd=./tocmd-sed \ + --smtp-server="$(pwd)/fake.sendmail" \ + tocmd.patch \ + && + grep "^To: [email protected]" msgtxt1 +' + test_expect_success $PREREQ 'cccmd works' ' clean_fake_sendmail && cp $patches cccmd.patch &&
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH V3] git-send-email.perl: Add --to-cmd
git-send-email.perl foreach my $t (@files) { · line 1308
Quoted 3 lines · Joe Perches
git-send-email.perl +3
-0+# Execute a command (ie: $to_cmd) to get a list of email addresses +# and return a results array +sub recipients_cmd(@) {
Do not use subroutine prototypes: they do not do what you think they do. In this case using prototype is unnecessary and can be dangerous.
git-send-email.perl foreach my $t (@files) { · line 1313
Quoted 5 lines
git-send-email.perl +5
-0+ my ($prefix, $what, $cmd, $file) = @_; + + my $sanitized_sender = sanitize_address($sender); + my @addresses = (); + open(F, "$cmd \Q$file\E |")
For the future: use lexical filehandles instead of globals
+ open(my $fh, "$cmd \Q$file\E |")
git-send-email.perl foreach my $t (@files) { · line 1314
Quoted 1 line
git-send-email.perl +1
-0+ or die "($prefix) Could not execute '$cmd'";
You should use quote_command from gitweb/gitweb.perl (should probably make it into Git.pm):
# quote the given arguments for passing them to the shell
# quote_command("command", "arg 1", "arg with ' and ! characters")
# => "'command' 'arg 1' 'arg with '\'' and '\!' characters'"
# Try to avoid using this function wherever possible.
sub quote_command {
return join(' ',
map { my $a = $_; $a =~ s/(['!])/'\\$1'/g; "'$a'" } @_ );
}Or use String::ShellQuote :-)
But that is for a cleanup patch; you are using what it is already there.
git-send-email.perl foreach my $t (@files) { · line 1318
Quoted 4 lines
git-send-email.perl +4
-0+ while(<F>) { + my $address = $_; + $address =~ s/^\s*//g; + $address =~ s/\n$//g;
Hmmm... why does it remove leading, but not trailing whitespace?
Quoted 10 lines
git-send-email.perl +10
-0+ $address = sanitize_address($address); + next if ($address eq $sanitized_sender and $suppress_from); + push @addresses, $address; + printf("($prefix) Adding %s: %s from: '%s'\n", + $what, $address, $cmd) unless $quiet; + } + close F + or die "($prefix) failed to close pipe to '$cmd'"; + return @addresses; +}
Signature · 3 lines
Jakub Narebski Poland ShadeHawk on #git
Re: [PATCH V3] git-send-email.perl: Add --to-cmd
Quoted 6 lines · Jakub Narebski
git-send-email.perl foreach my $t (@files) { · line 1308
Quoted 3 lines · Joe Perches
git-send-email.perl +3
-0+# Execute a command (ie: $to_cmd) to get a list of email addresses +# and return a results array +sub recipients_cmd(@) {Do not use subroutine prototypes: they do not do what you think they do. In this case using prototype is unnecessary and can be dangerous.
It can be removed. I was following the form of the other returned array in the code.
sub unique_email_list(@) {
Quoted 5 lines
git-send-email.perl foreach my $t (@files) { · line 1318
Quoted 4 lines
git-send-email.perl +4
-0+ while(<F>) { + my $address = $_; + $address =~ s/^\s*//g; + $address =~ s/\n$//g;Hmmm... why does it remove leading, but not trailing whitespace?
Unmodified from the current. I agree it should do both.
Re: [PATCH V3] git-send-email.perl: Add --to-cmd
Quoted 10 lines · Joe Perches
Quoted 6 lines · Jakub Narebski
git-send-email.perl foreach my $t (@files) { · line 1308
Quoted 3 lines · Joe Perches
git-send-email.perl +3
-0+# Execute a command (ie: $to_cmd) to get a list of email addresses +# and return a results array +sub recipients_cmd(@) {Do not use subroutine prototypes: they do not do what you think they do. In this case using prototype is unnecessary and can be dangerous.
It can be removed. I was following the form of the other returned array in the code.
While we generally follow the rule that you should use the style of the existing code, I think resaonable to discard that when the surrounding code with less than wizard-level understanding of the language.
In any case most of git-send-email.perl doesn't use prototypes, it's just 2-3 subs out of ~30.
PATCH v4 1/1 git-send-email.perl: Add --to-cmd
Add the ability to use a command line --to-cmd=cmd to create the list of "To:" addresses.
Used a shared routine for --cc-cmd and --to-cmd.
Did not use IPC::Open2, leaving that for Ævar if ever he decides to fix the other bugs he might find.
--- Documentation/git-send-email.txt | 8 +++++- git-send-email.perl | 51 +++++++++++++++++++++++++------------ t/t9001-send-email.sh | 18 +++++++++++++ 3 files changed, 59 insertions(+), 18 deletions(-)
Documentation/git-send-email.txt +7 -1
@@ -97,7 +97,7 @@ See the CONFIGURATION section for 'sendemail.multiedit'. Specify the primary recipient of the emails generated. Generally, this will be the upstream maintainer of the project involved. Default is the value of the 'sendemail.to' configuration value; if that is unspecified, - this will be prompted for. + and --to-cmd is not specified, this will be prompted for. + The --to option must be repeated for each user you want on the to list.
@@ -177,6 +177,12 @@ user is prompted for a password while the input is masked for privacy. Automating ~~~~~~~~~~ +--to-cmd=<command>:: + Specify a command to execute once per patch file which + should generate patch file specific "To:" entries. + Output of this command must be single email address per line. + Default is the value of 'sendemail.tocmd' configuration value. + --cc-cmd=<command>:: Specify a command to execute once per patch file which should generate patch file specific "Cc:" entries.
git-send-email.perl +34 -17
93 lines not on this page · raw message
t/t9001-send-email.sh +18 -0
@@ -201,6 +201,24 @@ test_expect_success $PREREQ 'Prompting works' ' grep "^To: [email protected]\$" msgtxt1 ' +test_expect_success $PREREQ 'tocmd works' ' + clean_fake_sendmail && + cp $patches tocmd.patch && + echo [email protected] >>tocmd.patch && + { + echo "#!$SHELL_PATH" + echo sed -n -e s/^tocmd--//p \"\$1\" + } > tocmd-sed && + chmod +x tocmd-sed && + git send-email \ + --from="Example <[email protected]>" \ + --to-cmd=./tocmd-sed \ + --smtp-server="$(pwd)/fake.sendmail" \ + tocmd.patch \ + && + grep "^To: [email protected]" msgtxt1 +' + test_expect_success $PREREQ 'cccmd works' ' clean_fake_sendmail && cp $patches cccmd.patch &&
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH V2] git-send-email.perl: Add --to-cmd
In reply to Junio C HamanoQuoted 19 lines · Junio C Hamano
git-send-email.perl foreach my $t (@files) { · line 1249
Quoted 5 lines · Joe Perches
git-send-email.perl +5
-0+ if (defined $to_cmd) { + open(F, "$to_cmd \Q$t\E |") + or die "(to-cmd) Could not execute '$to_cmd'"; + while(<F>) { + my $t = $_;"my $t" masks another $t in the outer scope; technically not a bug, but questionable as a style.
git-send-email.perl foreach my $t (@files) { · line 1254
Quoted 5 lines
git-send-email.perl +5
-0+ $t =~ s/^\s*//g; + $t =~ s/\n$//g; + next if ($t eq $sender and $suppress_from); + push @to, parse_address_line($t) + if defined $t; # sanitized/validated laterThis "if defined $t" makes my head hurt. Why?
Quoted 8 lines
* The "while (<F>)" loop wouldn't have given you an undef in $t in the first place;
* You would have got "Use of uninitialized value" warning at these two s/// statements if $t were undef; and
* Even if $t were undef, these two s/// statements would have made $t a defined, empty string.
all true.
Quoted 12 lines
git-send-email.perl foreach my $t (@files) { · line 1260
Quoted 6 lines
git-send-email.perl +6
-0+ printf("(to-cmd) Adding To: %s from: '%s'\n", + $t, $to_cmd) unless $quiet; + } + close F + or die "(to-cmd) failed to close pipe to '$to_cmd'"; + }In any case, this whole codeblock obviously is a copy-and-paste from corresponding $cc_cmd codepath, and I wonder if you can refactor the original into a common helper function first and then use it to make the addition of this feature a smaller patch.
Quoted 6 lines
if (defined $cc_cmd) {
push @cc, recipients_cmd($cc_cmd, 'cc');
}
if (defined $to_cmd) {
push @to, recipients_cmd($to_cmd, 'to');
}Overall, I believe it'll be more code, but all right.
Quoted 9 lines
If you did so, the first patch that refactors to create a helper function can address issues Ævar raised in the review to clean things up, no?
I notice that you use
parse_address_line()while $cc_cmd codepath doesn't. I haven't studied other codepaths deeply, but my gut feeling is that the reason why the $cc_cmd codepath does not callparse_address_line()before pushing the result to @cc is _not_ because strings on @cc shouldn't be sanitized (the codepath to parse "Cc: " callsparse_address_lineand pushes the result to @cc), but because the code is simply sloppy.
Probably, I wrote some of those lines...
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 11 lines · Julia Lawall
Quoted 9 lines · Joe Perches
Quoted 7 lines · Vasiliy Kulikov
Quoted 6 lines · Vasiliy Kulikov
Quoted 4 lines · Julia Lawall
I made some changes to git-send-email to get it to send mail to different people, ie a different set of addresses for each patch. Is that now possible with the standard version? If not I can submit a patch with my changes at some point.
I use git-send-email --cc-cmd=script_to_form_cc_list.
Quoted 21 lines
Quoted 2 lines
I believe that Julia means some mechanism to vary the "to" addresses for each patch, ie: some "--to-cmd=cmd".
Yes, sort of. I took the strategy of precomputing the To addresses, so I just have a collection of files that have different To and Cc addresses. But a --to-cmd option seems like a good idea too.
julia
Quoted 11 lines
Quoted 5 lines
I mean this:
for f in *.patch; do
CMD="script_to_form_cc_list $f"
git-send-email --cc-cmd="$CMD" ... "$f"
doneYou could also do that with a single line as the target cc-cmd receives each $f as argument.
git send-email --cc-cmd=script_to_form_cc_list ... *.patch
Thanks, all much saner solutions than my own. I should have read the manpages; I didn't know that format-patch has a --thread option or that send-email has --cc-cmd.
It does seem that a --to-cmd would also be beneficial.
-mfm
Signature · 5 lines
GPG-Key: 9AFE00EA -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html