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

[PATCH v4] send-email: Add simple email aliases format

From
Allen Hubbe <allenbh@gmail.com>
Date
May 22, 2015, 03:40 UTC
Message-ID
<9f88da801466c83331d02262855e8bef4164e5eb.1432266004.git.allenbh@gmail.com>

This format is more simple than the other alias file formats, so it may be preferred by some users. The format is as follows.

	<alias>: <address|alias>[, <address|alias>...]

Aliases are specified one per line. There is no line splitting. Anything on a line after and including a `#` symbol is considered a comment, and is ignored. Blank lines are ignored.

Example of the 'simple' format:
	alice: Alice W Land <awol@example.com>
	bob: Robert Bobbyton <bob@example.com>
	# this is a comment
	   # this is also a comment
	chloe: chloe@example.com
	abgroup: alice, bob # comment after an alias
	bcgrp: bob, chloe, Other <o@example.com>
Signed-off-by: Allen Hubbe <allenbh@gmail.com>
---
Notes:
    Note, v3 was sent in error.  This v4 presents changes since v2.
    
    This v4 extends the syntax to allow blank lines, and comments.  The test
    case is extended with comments added to alias file input.
    
    The Documentation/git-send-email.txt is updated with a description of
    the simple format.  A note is added for the other formats, directing
    readers to check the documentation of the email clients for a
    description.
 Documentation/git-send-email.txt | 24 +++++++++++++++++++++++-
 git-send-email.perl              |  8 +++++++-
 t/t9001-send-email.sh            | 27 +++++++++++++++++++++++++++
 3 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 804554609def..38ade31e0c28 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -383,7 +383,29 @@ sendemail.aliasesFile::
 
 sendemail.aliasFileType::
 	Format of the file(s) specified in sendemail.aliasesFile. Must be
-	one of 'mutt', 'mailrc', 'pine', 'elm', or 'gnus'.
+	one of 'simple', 'mutt', 'mailrc', 'pine', 'elm', or 'gnus'.
++
+If the format is 'simple', then the alias file format is described below.
+Descriptions of the other file formats to the following formats can be found in
+the documentation of the email program of the same name.
++
+This 'simple' format is is as follows.
++
+	<alias>: <address|alias>[, <address|alias>...]
++
+Aliases are specified one per line.  There is no line splitting.  Anything on a
+line after and including a `#` symbol is considered a comment, and is ignored.
+Blank lines are ignored.
++
+Example of the 'simple' format:
++
+	alice: Alice W Land <awol@example.com>
+	bob: Robert Bobbyton <bob@example.com>
+	# this is a comment
+	   # this is also a comment
+	chloe: chloe@example.com
+	abgroup: alice, bob # comment after an alias
+	bcgrp: bob, chloe, Other <o@example.com>
 
 sendemail.multiEdit::
 	If true (default), a single editor instance will be spawned to edit
diff --git a/git-send-email.perl b/git-send-email.perl
index e1e9b1460ced..716c2bc9479a 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -515,7 +515,13 @@ my %parse_alias = (
 			       $aliases{$alias} = [ split_addrs($addr) ];
 			  }
 		      } },
-
+	simple => sub { my $fh = shift; while (<$fh>) {
+		s/#.*$//;
+		next if /^\s*$/;
+		if (/^\s*(\S+)\s*:\s*(.+)$/) {
+			my ($alias, $addr) = ($1, $2);
+			$aliases{$alias} = [ split_addrs($addr) ];
+		}}},
 	gnus => sub { my $fh = shift; while (<$fh>) {
 		if (/\(define-mail-alias\s+"(\S+?)"\s+"(\S+?)"\)/) {
 			$aliases{$1} = [ $2 ];
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 7be14a4e37f7..12c1a0c76f1d 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -1549,6 +1549,33 @@ test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
 	grep "^!someone@example\.org!$" commandline1
 '
 
+test_expect_success $PREREQ 'sendemail.aliasfiletype=simple' '
+	clean_fake_sendmail && rm -fr outdir &&
+	git format-patch -1 -o outdir &&
+	{
+		echo "alice: Alice W Land <awol@example.com>"
+		echo "bob: Robert Bobbyton <bob@example.com>"
+		echo "# this is a comment"
+		echo "   # this is also a comment"
+		echo "chloe: chloe@example.com"
+		echo "abgroup: alice, bob # comment after an alias"
+		echo "bcgrp: bob, chloe, Other <o@example.com>"
+	} >~/.tmp-email-aliases &&
+	git config --replace-all sendemail.aliasesfile \
+		"$(pwd)/.tmp-email-aliases" &&
+	git config sendemail.aliasfiletype simple &&
+	git send-email \
+		--from="Example <nobody@example.com>" \
+		--to=alice --to=bcgrp \
+		--smtp-server="$(pwd)/fake.sendmail" \
+		outdir/0001-*.patch \
+		2>errors >out &&
+	grep "^!awol@example\.com!$" commandline1 &&
+	grep "^!bob@example\.com!$" commandline1 &&
+	grep "^!chloe@example\.com!$" commandline1 &&
+	grep "^!o@example\.com!$" commandline1
+'
+
 do_xmailer_test () {
 	expected=$1 params=$2 &&
 	git format-patch -1 &&
-- 
2.3.4
Next: Eric Sunshine
Message 1 of 10 in “send-email: Add simple email aliases format”
  1. send-email: Add simple email aliases formatAllen Hubbe, May 22, 2015
  2. Eric SunshineMay 22, 2015
  3. Allen HubbeMay 22, 2015
  4. Junio C HamanoMay 22, 2015
  5. Allen HubbeMay 22, 2015
  6. Junio C HamanoMay 22, 2015
  7. Allen HubbeMay 22, 2015
  8. Eric SunshineMay 22, 2015
  9. Allen HubbeMay 22, 2015
  10. Eric SunshineMay 22, 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.