git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: David Brown <git@davidb.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] git-send-email: Add --suppress-all-from option.
Date: Fri, 21 Dec 2007 09:43:48 -0800	[thread overview]
Message-ID: <7vfxxw7xkb.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <1198216860-487-1-git-send-email-git@davidb.org> (David Brown's message of "Thu, 20 Dec 2007 22:01:00 -0800")

David Brown <git@davidb.org> writes:

> Sometimes, it is useful to be able to send a patch to a third party
> without the author of the patch being copied on the message.

I would agree with the cause, but not necessarily with the
execution.

> +--suppress-all-from, --no-suppress-all-from::
> +        If this is set, do not add the From: address to the cc: list,
> +        even if it is different than the person sending the email.
> +        Default is the value of the 'sendemail.suppressallfrom'
> +        configuration value; if that is unspecified, default to
> +        -no-suppress-all-from.

The option name feels as if it is somehow affecting From: but
this is all about recipients.  It needs to be named better.

Even more importantly, git-send-email has too many places that
pick up additional recipients.  I doubt --suppress-foo to
suppress one such source "foo" is sustainable.  We should try to
clean up the mess, not adding to it.

So let's analyze the current situation first.  It seems that we
currently pick up the list of recipients from the following
places:

 * obviously, --to command line;
 * mbox Cc: header lines;
 * mbox From: header lines;
 * lots-of-email first line
 * $cc_cmd output;
 * Signed-off-by: lines in body;
 * Cc: lines in body;

The --no-signed-off-cc option is about omitting the last two
from the recipients.  We do not have a way to squelch other
sources of extra recipients, hence the need for your patch.

The --suppress-from option is about not giving an extra copy to
the sender.  It is "suppress from-address from the recipient
list", so the option name makes sense.

Your --suppress-all-from, from a cursory read of your patch,
omits only mbox Cc: and From: line recipients -- it is far from
"all", isn't it?  --signed-off-cc defaults to true so you would
need to suppress that at least to call it "all".

A cleaner approach might be:

 - introduce a helper function add_to_recipients that take \@cc,
   $recipient and the "source class".  Make this function
   responsible for not adding the sender to the list
   (i.e. --suppress-from, which is currently checked
   everywhere), and for not adding recipients from specified
   classes of sources, like this:

        sub add_to_recipients {
                my ($cc, $source, $recipient) = @_;
                return 0 if ($suppress_from and $sender eq $recipient);
                return 0 if ($suppressed_recipient_source{$source});
                push @$cc, $recipient;
                return 1;
        }

   Instead of returning 1 unconditionally, it might make sense
   to omit pushing duplicate here and to return 0 when
   $recipient was already in @$cc.

 - adjust the places where "push @cc" happens to use the above
   helper; the existing suppress logic in the callers can and
   should be removed as the add_to_recipients will be
   responsible for it, like this (an example for cc-cmd part):

        if (defined $cc_cmd) {
        open(F, "$cc_cmd $t |")
                or die "(cc-cmd) Could not execute '$cc_cmd'";
        while(<F>) {
                my $c = $_;
                $c =~ s/^\s*//g;
                $c =~ s/\n$//g;
-               next if ($c eq $sender and $suppress_from);
-               push @cc, $c;
+               next if (!add_to_recipients(\@cc, 'cccmd', $c));
                printf("(cc-cmd) Adding cc: %s from: '%s'\n",
                        $c, $cc_cmd) unless $quiet;
        }

 - define a global %suppressed_recipient_source hash to be used
   in add_to_recipients().  The existing --no-signed-off-cc is
   about adding two sources to this hash.

 - make the %suppressed_recipient_source configurable from the
   command line and repository configuration.

As to the "recipient source" classes, I think they can be
categorized as:

 * 'cc', to cover mbox Cc: header, lots-of-email first line, and
    Cc: lines in body;

 * 'sob', to cover Signed-off-by: lines in body;

 * 'cccmd', to cover $cc_cmd output;

Hmm?

  parent reply	other threads:[~2007-12-21 17:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-21  6:01 [PATCH] git-send-email: Add --suppress-all-from option David Brown
2007-12-21 11:05 ` Joel Becker
2007-12-21 11:14 ` Brian Swetland
2007-12-21 17:43 ` Junio C Hamano [this message]
2007-12-21 19:21   ` Joel Becker
2007-12-22  0:55     ` Theodore Tso
2007-12-21 22:37   ` David Brown
2007-12-24 19:01 ` [PATCH] git-send-email: Generalize auto-cc recipient mechanism David Brown
2007-12-24 21:03   ` Joel Becker
2007-12-24 21:26     ` [PATCH] git-send-email: Add --suppress-cc all David Brown
2007-12-24 21:59       ` Joel Becker
2007-12-24 21:36 ` [PATCH] git-send-email: Generalize auto-cc recipient mechanism David Brown
2007-12-25 21:04   ` Junio C Hamano
2007-12-26  3:39     ` David Brown
2007-12-26  3:56     ` David Brown
2007-12-26  4:54       ` Sean
2007-12-26  5:32         ` David Brown

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=7vfxxw7xkb.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@davidb.org \
    --cc=git@vger.kernel.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 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 NNTP newsgroup(s).