git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-send-email: Add ability to cc: any "trailers" from commit message

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 31, 2016, 17:54 UTC
Message-ID
<xmqqpooo259c.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<b2aa91d59a6cdd468bcbe85b45807cc1b82b23ed.1472588158.git.joe@perches.com>
Joe Perches <joe@perches.com> writes:
> Many commits have various forms of trailers similar to
>      "Acked-by: Name <address>" and "Reported-by: Name <address>"
>
> Add the ability to cc these trailers when using git send-email.

I thought you were asking what we call these "<token> followed by <colon>" at the end of the log message, and "footers or trailers" was the answer.

I do not have a strong objection against limiting to "-by:" lines; for one thing, it would automatically avoid having to worry about "Bug-ID:" and other trailers that won't have e-mail address at all.

But if you are _only_ picking up "-by:" lines, then calling this option "trailers" is way too wide and confusing. I do not think there is any specific name for "-by:" lines, though. Perhaps you would need to invent some name that has "-by" as a substring.

"any-by"?  or just "by"?  I dunno.
Show 5 quoted lines
>  if ($suppress_cc{'all'}) {
> -	foreach my $entry (qw (cccmd cc author self sob body bodycc)) {
> +	foreach my $entry (qw (cccmd cc author self sob body bodycc trailers)) {
>  		$suppress_cc{$entry} = 1;
>  	}
OK.
Show 9 quoted lines
> @@ -448,7 +448,7 @@ $suppress_cc{'self'} = $suppress_from if defined $suppress_from;
>  $suppress_cc{'sob'} = !$signed_off_by_cc if defined $signed_off_by_cc;
>  
>  if ($suppress_cc{'body'}) {
> -	foreach my $entry (qw (sob bodycc)) {
> +	foreach my $entry (qw (sob bodycc trailers)) {
>  		$suppress_cc{$entry} = 1;
>  	}
>  	delete $suppress_cc{'body'};
OK.
Show 6 quoted lines
> @@ -1545,7 +1545,7 @@ foreach my $t (@files) {
>  	# Now parse the message body
>  	while(<$fh>) {
>  		$message .=  $_;
> -		if (/^(Signed-off-by|Cc): (.*)$/i) {
> +		if (/^(Signed-off-by|Cc|[^\s]+[_-]by): (.*)$/i) {
Micronits:
 (1) do you really want to grab a run of any non-blanks?  Don't
     you want to exclude at least a colon?
 (2) allowing an underscore looks a bit unusual.  
Show 6 quoted lines
> @@ -1555,6 +1555,12 @@ foreach my $t (@files) {
>  			} else {
>  				next if $suppress_cc{'sob'} and $what =~ /Signed-off-by/i;
>  				next if $suppress_cc{'bodycc'} and $what =~ /Cc/i;
> +				next if $suppress_cc{'trailers'} and $what !~ /Signed-off-by/i && $what =~ /by$/i;
> +			}

It is a bit unfortunate that S-o-b is a subset of any-by that forces you to do this.

Show 5 quoted lines
> +			if ($c !~ /.+@.+/) {
> +				printf("(body) Ignoring %s from line '%s'\n",
> +				       $what, $_) unless $quiet;
> +				next;
>  			}
This check is new and applies to sob/cc, too.

I am aware of the fact that people sometimes write only a name with no e-mail address when giving credit to a third-party and we want to avoid upsetting the underlying MTA by feeding it a non-address.

Looking at existing helper subs like extract_valid_address and sanitize_address that all addresses we pass to the MTA go through, it appears to me that we try to support an addr-spec with only local-part without @domain, so this new check might turn out to be too strict from that point of view, but on the other hand I suspect it won't be a huge issue because the addresses in the footers are for public consumption and it may not make much sense to have a local-only address there. I dunno.

>  			push @cc, $c;
>  			printf("(body) Adding cc: %s from line '%s'\n",
Previous: Joe PerchesNext: Joe Perches
Message 2 of 5 in “git-send-email: Add ability to cc: any "trailers" from commit message”
  1. git-send-email: Add ability to cc: any "trailers" from commit messageJoe Perches, Aug 30, 2016
  2. Junio C HamanoAug 31, 2016
  3. Joe PerchesAug 31, 2016
  4. Junio C HamanoAug 31, 2016
  5. Joe PerchesAug 31, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.