All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@citrix.com>
To: Lars Kurth <lars.kurth@citrix.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Tim Deegan <tim@xen.org>, Julien Grall <julien.grall@arm.com>,
	Jan Beulich <jbeulich@suse.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH for-4.11 v3 1/1] Add new add_maintainers.pl script to optimise the workflow when using git format-patch with get_maintainer.pl
Date: Fri, 4 May 2018 18:43:54 +0100	[thread overview]
Message-ID: <23276.39898.414930.954246@mariner.uk.xensource.com> (raw)
In-Reply-To: <de27a6551f975c91ff38d625063e843b7612afb5.1525421849.git.lars.kurth@citrix.com>

Thanks.  This is much better :-).  I have reviewed this for style,
obvious bugs, and the semantics in the doc comment.  I haven't tried
to follow the algorithm in detail, but I reckon it's probably OK.

I have reordered the patch (and hence the file) to make the grouping
of my comments make more sense.

Lars Kurth writes ("[PATCH for-4.11 v3 1/1] Add new add_maintainers.pl script to optimise the workflow when using git format-patch with get_maintainer.pl"):
> +  --inspatch (top|ccbody|cc---|none) | -p (top|ccbody|cc---|none)
> +    Insert email addresses into *.patch files according to the POLICY
> +    See section POLICY:
> +  --inscover (top|ccend|none) | -c (top|ccend|none)
> +    Insert email addresses into cover letteraccording to the POLICY
> +    See section PROCESSING POLICY:

I'm afraid that I don't understand which addresses are added where,
from the documentation.  In particular, what happens without --tags or
--tagscc ?  Also you should define `tag'; it has a lot of different
meanings, some subtly different, and it is not completely clear which
one you mean.

I think you should formally state the default behaviour.  Something
like:

  By default:
  * get_maintainer is called on each patch to find email addresses
    of maintainers/reviewers for that patch; these are added
    to the patch body near the CC section.
  * further email addresses are found in each patch's commit
    message tags (CC, signed-off-by, reviewed-by, etc.)
  * All of the above addresses are added to the CC mail headers
    of each patch
  * All of the above addresses are added to the CC mail headers
    of the cover letter

I suspect that what I have above is not the real behaviour.  You
should write what is true in that kind of style :-).

> +my $patch_prefix = "0"; # Use a 0, such that v* does not get picked up
> +                        # Obviously this will only work for series with
> +                        # < 999 patches, which should be fine

I don't understand the purpose of this:

> +if ($rerollcount > 0) {
> +    $patch_prefix = "v".$rerollcount;
> +}
...
> +my $pattern = $patch_dir.'/'.$patch_prefix.'*'.$patch_ext;
> +print "Then perform:\n".
> +      "git send-email -to xen-devel\@lists.xenproject.org ".
> +      $patch_dir.'/'.$patch_prefix."*.patch"."\n";

What files matching *.patch exist here that should not be processed ?
If the answer is none then $patch_prefix is redundant, I think ?


> +foreach my $file (@patches) {
> +    if ($file =~ /\Q$cover_letter\E/) {

I know you had me look at this over your shoulder and I said it was
right, but I think in fact this would match hypothetical files
     $patch_dir/0020-do-something-about-0000-cover-letter.patch

I think you need to expect a /.  So one of

  +    if ($file =~ /\/\Q$cover_letter\E/) {
  +    if ($file =~ m{/\Q$cover_letter\E}) {

> +print "Then perform:\n".
> +      "git send-email -to xen-devel\@lists.xenproject.org ".
> +      $patch_dir.'/'.$patch_prefix."*.patch"."\n";
> +
> +exit 0;
> +
> +my $readmailinglists = 0;
> +my @mailinglists = ();

This is a very curious structure.  These assignments are never
executed (but I guess the program works anyway).  I would recommend
moving the main program to the bottom of the file.

> +sub getmailinglists () {
> +   # Read mailing list from MAINTAINERS file and copy
> +   # a list of e-mail addresses to @mailinglists
> +    if (!$readmailinglists) {

I suggest you rename this variable $getmailinglists_done or
something.  As it is it is confusing because `read' might be the
present tense, but then the sense is wrong.

Also, you might find it better to use a structure like one of
      if ($getmailingslists_done) { return; }
      return if $getmailingslists_done;

> +        if (-e $maintainers) {
...
> +            print "Warning: Mailing lists will be treated as CC's\n";
> +        }
> +    # Don't try again, even if the MAINTAINERS file does not exist
> +    $readmailinglists = 1;
> +    # Remove any duplicates
> +    @mailinglists = uniq @mailinglists;
> +    }

Indentation here is misleading.  (But this will go away if you adopt
my suggestion above).

> +sub ismailinglist ($) {
> +    my ($check) = @_;
> +    # Get the mailing list information
> +    getmailinglists();
> +    # Do the check
> +    if ( grep { $_ eq $check} @mailinglists) {

Rather than uniq above, and then grep here, you could use a hash
%mailinglists.  That would be more idiomatic and also less code and
faster.  But as it is is tolerable.

> +sub getmaintainers ($$$) {
> +    my ($file, $rto, $rcc) = @_;
> +    my $get_maintainer_args = join " ", @get_maintainer_args;
> +    my $cmd = "$get_maintainer $get_maintainer_args <$file";
...
> +    open($fh, "-|", $cmd)
> +        or die "Failed to open '$cmd'\n";

You should use the array form of piped open, rather than this string
joining.  That way arguments containing spaces make their way through
correct.

> +    if (! -e $get_maintainer) {
> +        die "$tool: The tool requires $get_maintainer\n";

I still don't like this check.  What if the user specifies an
implementation of $get_maintainer which is on the PATH ?

> +    while(my $line = <$fh>) {
...
> +    }
> +    close $fh;

You need to check the errors here.  See the `perldoc -f close'.

> +        if ($tags & !$tagscc) {

You mean &&, not &.

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-05-04 17:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-04  8:36 [PATCH for-4.11 v3 0/1] Add new add_maintainers.pl script to optimise the workflow when using git format-patch with get_maintainer.pl Lars Kurth
2018-05-04  8:36 ` [PATCH for-4.11 v3 1/1] " Lars Kurth
2018-05-04 17:43   ` Ian Jackson [this message]
2018-05-05  7:57     ` Lars Kurth
2018-05-08 10:48       ` Ian Jackson
2018-05-08 11:25         ` Lars Kurth
2018-05-10 11:38   ` George Dunlap
2018-05-10 11:39     ` George Dunlap
2018-05-10 13:02     ` George Dunlap
2018-05-10 22:14       ` Lars Kurth
2018-05-10 22:04     ` Lars Kurth

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=23276.39898.414930.954246@mariner.uk.xensource.com \
    --to=ian.jackson@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=lars.kurth@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.