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

Re: [PATCH] git-send-email.perl: Add sendmail aliases support

From
Junio C Hamano <gitster@pobox.com>
Date
May 21, 2015, 20:19 UTC
Message-ID
<xmqqioblisyk.fsf@gitster.dls.corp.google.com>
In-Reply-To
<3f1091c3de6e4e62037bc3c84c69026e33ee9707.1432229888.git.allenbh@gmail.com>
Allen Hubbe <allenbh@gmail.com> writes:
Show 15 quoted lines
> diff --git a/git-send-email.perl b/git-send-email.perl
> index e1e9b14..5f2ec0d 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -515,7 +515,12 @@ my %parse_alias = (
>  			       $aliases{$alias} = [ split_addrs($addr) ];
>  			  }
>  		      } },
> -
> +	sendmail => sub { my $fh = shift; while (<$fh>) {
> +		next if /^$|^#|^\s/;
> +		if (/^(\S+)\s*:\s*(.*?)\\?$/) {
> +			my ($alias, $addr) = ($1, $2);
> +			$aliases{$alias} = [ split_addrs($addr) ];
> +		}}},
Let me unfold the line only to make commenting it easier.
	sendmail => sub {
        	my $fh = shift;
                while (<$fh>) {
			next if /^$|^#|^\s/;
			if (/^(\S+)\s*:\s*(.*?)\\?$/) {
				my ($alias, $addr) = ($1, $2);
				$aliases{$alias} = [ split_addrs($addr) ];
			}
		}
	},

It is probably OK to omit support for folded lines, but wouldn't it be easy enough to be a bit more helpful to give a warning when you find such lines in the input? Otherwise you will leave the users wondering why some of their aliases work while others don't.

Perhaps like this (this is not even an output from "diff" but typed in my MUA, so there may be typos---take it just as illustrating ideas)?

That way, users can fold the input themselves and try again if they wanted to. The warning _may_ have to be squelched after a few hits to keep the result usable, though.

	sendmail => sub {
        	my $fh = shift;
                while (<$fh>) {
-			next if /^$|^#|^\s/;
-			if (/^(\S+)\s*:\s*(.*?)\\?$/) {
+			next if /^$|^#/;
+			if (/^\s/ || /\\$/) {
+				print STDERR "$.: $_";
+				print STDERR "continuation lines in alias not supported\n";
+				next;
+			}
+			if (/^(\S+)\s*:\s*(.*)$/) {
				my ($alias, $addr) = ($1, $2);
				$aliases{$alias} = [ split_addrs($addr) ];
			}
		}
	},
Thanks.
Previous: Allen HubbeNext: Allen Hubbe
Message 2 of 8 in “git-send-email.perl: Add sendmail aliases support”
  1. git-send-email.perl: Add sendmail aliases supportAllen Hubbe, May 21, 2015
  2. Junio C HamanoMay 21, 2015
  3. Allen HubbeMay 21, 2015
  4. Eric SunshineMay 21, 2015
  5. Allen HubbeMay 21, 2015
  6. Junio C HamanoMay 21, 2015
  7. Allen HubbeMay 21, 2015
  8. Junio C HamanoMay 21, 2015

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.