From: Junio C Hamano <gitster@pobox.com>
To: Joe Perches <joe@perches.com>
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Julia Lawall" <julia@diku.dk>, git <git@vger.kernel.org>,
"Vasiliy Kulikov" <segooon@gmail.com>,
"matt mooney" <mfmooney@gmail.com>,
kernel-janitors@vger.kernel.org,
"Dan Carpenter" <error27@gmail.com>
Subject: Re: [PATCH V2] git-send-email.perl: Add --to-cmd
Date: Thu, 23 Sep 2010 15:37:05 -0700 [thread overview]
Message-ID: <7v62xwqe7i.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1285267520.31572.34.camel@Joe-Laptop> (Joe Perches's message of "Thu\, 23 Sep 2010 11\:45\:20 -0700")
Joe Perches <joe@perches.com> writes:
> + 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.
> + $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.
> + 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?
next prev parent reply other threads:[~2010-09-23 22:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <AANLkTinsM5jdU194FR8L3hTvBXk0Tr_oV2E5752NOUpq@mail.gmail.com>
[not found] ` <AANLkTikkJNwF4LS9rx5=bHM2R0Pm751Y1u9V8iAt0w1A@mail.gmail.com>
[not found] ` <1285227413.7286.47.camel@Joe-Laptop>
[not found] ` <Pine.LNX.4.64.1009231054230.15528@ask.diku.dk>
2010-09-23 9:05 ` threaded patch series Joe Perches
[not found] ` <20100923090931.GA29789@albatros>
[not found] ` <20100923120024.GA26715@albatros>
[not found] ` <1285253867.31572.13.camel@Joe-Laptop>
[not found] ` <Pine.LNX.4.64.1009231757090.11585@ask.diku.dk>
2010-09-23 17:17 ` [RFC PATCH] sit-send-email.pl: Add --to-cmd Joe Perches
2010-09-23 17:29 ` Ævar Arnfjörð Bjarmason
2010-09-23 17:46 ` Joe Perches
2010-09-23 17:50 ` Ævar Arnfjörð Bjarmason
2010-09-23 18:45 ` [PATCH V2] git-send-email.perl: " Joe Perches
2010-09-23 19:57 ` matt mooney
2010-09-23 22:37 ` Junio C Hamano [this message]
2010-09-23 23:16 ` Ævar Arnfjörð Bjarmason
2010-09-24 1:18 ` [PATCH V3] " Joe Perches
2010-09-24 15:32 ` Jakub Narebski
2010-09-24 16:06 ` Joe Perches
2010-09-24 16:47 ` Ævar Arnfjörð Bjarmason
2010-09-24 17:03 ` [PATCH V4] " Joe Perches
2010-09-24 1:20 ` [PATCH V2] " Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7v62xwqe7i.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=error27@gmail.com \
--cc=git@vger.kernel.org \
--cc=joe@perches.com \
--cc=julia@diku.dk \
--cc=kernel-janitors@vger.kernel.org \
--cc=mfmooney@gmail.com \
--cc=segooon@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).