From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Perches Subject: Re: [PATCH V2] git-send-email.perl: Add --to-cmd Date: Thu, 23 Sep 2010 18:20:54 -0700 Message-ID: <1285291254.25928.223.camel@Joe-Laptop> References: <1285227413.7286.47.camel@Joe-Laptop> <20100923090931.GA29789@albatros> <20100923120024.GA26715@albatros> <1285253867.31572.13.camel@Joe-Laptop> <1285262237.31572.18.camel@Joe-Laptop> <1285263993.31572.25.camel@Joe-Laptop> <1285267520.31572.34.camel@Joe-Laptop> <7v62xwqe7i.fsf@alter.siamese.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: =?ISO-8859-1?Q?=C6var_Arnfj=F6r=F0?= Bjarmason , Julia Lawall , git , Vasiliy Kulikov , matt mooney , kernel-janitors@vger.kernel.org, Dan Carpenter To: Junio C Hamano X-From: git-owner@vger.kernel.org Fri Sep 24 03:21:03 2010 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OywyE-0000US-5k for gcvg-git-2@lo.gmane.org; Fri, 24 Sep 2010 03:21:02 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756313Ab0IXBU4 convert rfc822-to-quoted-printable (ORCPT ); Thu, 23 Sep 2010 21:20:56 -0400 Received: from mail.perches.com ([173.55.12.10]:2325 "EHLO mail.perches.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752504Ab0IXBUz (ORCPT ); Thu, 23 Sep 2010 21:20:55 -0400 Received: from [192.168.1.156] (unknown [192.168.1.156]) by mail.perches.com (Postfix) with ESMTP id AA1B024368; Thu, 23 Sep 2010 18:20:48 -0700 (PDT) In-Reply-To: <7v62xwqe7i.fsf@alter.siamese.dyndns.org> X-Mailer: Evolution 2.30.3 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: On Thu, 2010-09-23 at 15:37 -0700, Junio C Hamano wrote: > Joe Perches writes: >=20 > > + if (defined $to_cmd) { > > + open(F, "$to_cmd \Q$t\E |") > > + or die "(to-cmd) Could not execute '$to_cmd'"; > > + while() { > > + my $t =3D $_; >=20 > "my $t" masks another $t in the outer scope; technically not a bug, b= ut > questionable as a style. >=20 > > + $t =3D~ s/^\s*//g; > > + $t =3D~ s/\n$//g; > > + next if ($t eq $sender and $suppress_from); > > + push @to, parse_address_line($t) > > + if defined $t; # sanitized/validated later >=20 > This "if defined $t" makes my head hurt. Why? >=20 > * The "while ()" loop wouldn't have given you an undef in $t in t= he > first place; >=20 > * You would have got "Use of uninitialized value" warning at these t= wo > s/// statements if $t were undef; and >=20 > * Even if $t were undef, these two s/// statements would have made $= t a > defined, empty string. all true. > > + 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'"; > > + } >=20 > 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. >=20 > 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. > If you did so, the first patch that refactors to create a helper func= tion > can address issues =C3=86var raised in the review to clean things up,= no? > I notice that you use parse_address_line() while $cc_cmd codepath doe= sn'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() be= fore > pushing the result to @cc is _not_ because strings on @cc shouldn't b= e > sanitized (the codepath to parse "Cc: " calls parse_address_line and > pushes the result to @cc), but because the code is simply sloppy. Probably, I wrote some of those lines...