[PATCH 06/22] mailmap tests: modernize syntax & test idioms

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Refactor the mailmap tests to:

 * Setup "actual" test files in the body of "test_expect_success"

 * Don't have X of "test_expect_success X Y" be an unquoted string.

 * Not to carry over test config between tests, and instead use
   "test_config".

 * Replace various "echo" a line-at-a-time patterns with here-docs.

 * Change a case of "log.mailmap=False" to use the lower-case
   "false". Both work, but this ends up in git-config's boolean
   parsing and these atypical values are tested for elsewhere. Let's
   use the lower-case to not draw the reader's attention to this
   abnormality.

 * Remove commentary asserting that things work a given way in favor
   of simply testing for it, i.e. in the case of a .mailmap file
   outside of the repository.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
---
 t/t4203-mailmap.sh | 473 ++++++++++++++++++++++++++-------------------
 1 file changed, 274 insertions(+), 199 deletions(-)

diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 034a78aba1..61d1b62317 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -12,7 +12,7 @@ fuzz_blame () {
 	" "$@"
 }
 
-test_expect_success setup '
+test_expect_success 'setup commits and contacts file' '
 	cat >contacts <<-EOF &&
 	$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
 	nick1 <bugs@xxxxxxxxxx>
@@ -66,128 +66,164 @@ test_expect_success 'check-mailmap bogus contact' '
 	test_must_fail git check-mailmap bogus
 '
 
-cat >expect << EOF
-$GIT_AUTHOR_NAME (1):
-      initial
-
-nick1 (1):
-      second
+test_expect_success 'No mailmap' '
+	cat >expect <<-EOF &&
+	$GIT_AUTHOR_NAME (1):
+	      initial
 
-EOF
+	nick1 (1):
+	      second
 
-test_expect_success 'No mailmap' '
+	EOF
 	git shortlog HEAD >actual &&
 	test_cmp expect actual
 '
 
-cat >expect <<\EOF
-Repo Guy (1):
-      initial
+test_expect_success 'setup default .mailmap' '
+	cat >default.map <<-EOF
+	Repo Guy <$GIT_AUTHOR_EMAIL>
+	EOF
+'
+
+test_expect_success 'test default .mailmap' '
+	test_when_finished "rm .mailmap" &&
+	cp default.map .mailmap &&
 
-nick1 (1):
-      second
+	cat >expect <<-\EOF &&
+	Repo Guy (1):
+	      initial
 
-EOF
+	nick1 (1):
+	      second
 
-test_expect_success 'default .mailmap' '
-	echo "Repo Guy <$GIT_AUTHOR_EMAIL>" > .mailmap &&
+	EOF
 	git shortlog HEAD >actual &&
 	test_cmp expect actual
 '
 
-# Using a mailmap file in a subdirectory of the repo here, but
-# could just as well have been a file outside of the repository
-cat >expect <<\EOF
-Internal Guy (1):
-      second
+test_expect_success 'mailmap.file set' '
+	test_when_finished "rm .mailmap" &&
+	cp default.map .mailmap &&
 
-Repo Guy (1):
-      initial
+	test_config mailmap.file internal.map &&
+	cat >internal.map <<-\EOF &&
+	Internal Guy <bugs@xxxxxxxxxx>
+	EOF
 
-EOF
-test_expect_success 'mailmap.file set' '
-	mkdir -p internal_mailmap &&
-	echo "Internal Guy <bugs@xxxxxxxxxx>" > internal_mailmap/.mailmap &&
-	git config mailmap.file internal_mailmap/.mailmap &&
+	cat >expect <<-\EOF &&
+	Internal Guy (1):
+	      second
+
+	Repo Guy (1):
+	      initial
+
+	EOF
 	git shortlog HEAD >actual &&
-	test_cmp expect actual
+	test_cmp expect actual &&
+
+	# The internal_mailmap/.mailmap file is an a subdirectory, but
+	# as shown here it can also be outside the repository
+	test_when_finished "rm -rf sub-repo" &&
+	git clone . sub-repo &&
+	(
+		cd sub-repo &&
+		cp ../.mailmap . &&
+		git config mailmap.file ../internal.map &&
+		git shortlog HEAD >actual &&
+		test_cmp ../expect actual
+	)
 '
 
-cat >expect <<\EOF
-External Guy (1):
-      initial
+test_expect_success 'mailmap.file override' '
+	test_config mailmap.file internal.map &&
+	cat >internal.map <<-EOF &&
+	Internal Guy <bugs@xxxxxxxxxx>
+	External Guy <$GIT_AUTHOR_EMAIL>
+	EOF
 
-Internal Guy (1):
-      second
+	cat >expect <<-\EOF &&
+	External Guy (1):
+	      initial
 
-EOF
-test_expect_success 'mailmap.file override' '
-	echo "External Guy <$GIT_AUTHOR_EMAIL>" >> internal_mailmap/.mailmap &&
-	git config mailmap.file internal_mailmap/.mailmap &&
+	Internal Guy (1):
+	      second
+
+	EOF
 	git shortlog HEAD >actual &&
 	test_cmp expect actual
 '
 
-cat >expect <<\EOF
-Repo Guy (1):
-      initial
+test_expect_success 'mailmap.file non-existent' '
+	test_when_finished "rm .mailmap" &&
+	cp default.map .mailmap &&
 
-nick1 (1):
-      second
+	cat >expect <<-\EOF &&
+	Repo Guy (1):
+	      initial
 
-EOF
+	nick1 (1):
+	      second
 
-test_expect_success 'mailmap.file non-existent' '
-	rm internal_mailmap/.mailmap &&
-	rmdir internal_mailmap &&
+	EOF
 	git shortlog HEAD >actual &&
 	test_cmp expect actual
 '
 
-cat >expect <<\EOF
-Internal Guy (1):
-      second
+test_expect_success 'name entry after email entry' '
+	test_when_finished "rm .mailmap" &&
+	cp default.map .mailmap &&
 
-Repo Guy (1):
-      initial
+	test_config mailmap.file internal.map &&
+	cat >internal.map <<-\EOF &&
+	<bugs@xxxxxxxxxx> <bugs@xxxxxxxxxx>
+	Internal Guy <bugs@xxxxxxxxxx>
+	EOF
 
-EOF
+	cat >expect <<-\EOF &&
+	Internal Guy (1):
+	      second
+
+	Repo Guy (1):
+	      initial
+
+	EOF
 
-test_expect_success 'name entry after email entry' '
-	mkdir -p internal_mailmap &&
-	echo "<bugs@xxxxxxxxxx> <bugs@xxxxxxxxxx>" >internal_mailmap/.mailmap &&
-	echo "Internal Guy <bugs@xxxxxxxxxx>" >>internal_mailmap/.mailmap &&
 	git shortlog HEAD >actual &&
 	test_cmp expect actual
 '
 
-cat >expect <<\EOF
-Internal Guy (1):
-      second
+test_expect_success 'name entry after email entry, case-insensitive' '
+	test_when_finished "rm .mailmap" &&
+	cp default.map .mailmap &&
 
-Repo Guy (1):
-      initial
+	test_config mailmap.file internal.map &&
+	cat >internal.map <<-\EOF &&
+	<bugs@xxxxxxxxxx> <bugs@xxxxxxxxxx>
+	Internal Guy <BUGS@xxxxxxxxxx>
+	EOF
 
-EOF
+	cat >expect <<-\EOF &&
+	Internal Guy (1):
+	      second
+
+	Repo Guy (1):
+	      initial
+
+	EOF
 
-test_expect_success 'name entry after email entry, case-insensitive' '
-	mkdir -p internal_mailmap &&
-	echo "<bugs@xxxxxxxxxx> <bugs@xxxxxxxxxx>" >internal_mailmap/.mailmap &&
-	echo "Internal Guy <BUGS@xxxxxxxxxx>" >>internal_mailmap/.mailmap &&
 	git shortlog HEAD >actual &&
 	test_cmp expect actual
 '
 
-cat >expect << EOF
-$GIT_AUTHOR_NAME (1):
-      initial
+test_expect_success 'No mailmap files, but configured' '
+	cat >expect <<-EOF &&
+	$GIT_AUTHOR_NAME (1):
+	      initial
 
-nick1 (1):
-      second
+	nick1 (1):
+	      second
 
-EOF
-test_expect_success 'No mailmap files, but configured' '
-	rm -f .mailmap internal_mailmap/.mailmap &&
+	EOF
 	git shortlog HEAD >actual &&
 	test_cmp expect actual
 '
@@ -205,11 +241,16 @@ test_expect_success 'setup mailmap blob tests' '
 	printf "Tricky Guy <$GIT_AUTHOR_EMAIL>" >no-newline &&
 	git add just-bugs both no-newline &&
 	git commit -m "my mailmaps" &&
-	echo "Repo Guy <$GIT_AUTHOR_EMAIL>" >.mailmap &&
-	echo "Internal Guy <$GIT_AUTHOR_EMAIL>" >internal.map
+
+	cat >internal.map <<-EOF
+	Internal Guy <$GIT_AUTHOR_EMAIL>
+	EOF
 '
 
 test_expect_success 'mailmap.blob set' '
+	test_when_finished "rm .mailmap" &&
+	cp default.map .mailmap &&
+
 	cat >expect <<-\EOF &&
 	Blob Guy (1):
 	      second
@@ -223,6 +264,9 @@ test_expect_success 'mailmap.blob set' '
 '
 
 test_expect_success 'mailmap.blob overrides .mailmap' '
+	test_when_finished "rm .mailmap" &&
+	cp default.map .mailmap &&
+
 	cat >expect <<-\EOF &&
 	Blob Guy (2):
 	      initial
@@ -250,6 +294,9 @@ test_expect_success 'mailmap.file overrides mailmap.blob' '
 '
 
 test_expect_success 'mailmap.blob can be missing' '
+	test_when_finished "rm .mailmap" &&
+	cp default.map .mailmap &&
+
 	cat >expect <<-\EOF &&
 	Repo Guy (1):
 	      initial
@@ -267,11 +314,15 @@ test_expect_success 'mailmap.blob defaults to off in non-bare repo' '
 	(
 		cd non-bare &&
 		test_commit one .mailmap "Fake Name <$GIT_AUTHOR_EMAIL>" &&
-		echo "     1	Fake Name" >expect &&
+		cat >expect <<-\EOF &&
+		     1	Fake Name
+		EOF
 		git shortlog -ns HEAD >actual &&
 		test_cmp expect actual &&
 		rm .mailmap &&
-		echo "     1	$GIT_AUTHOR_NAME" >expect &&
+		cat >expect <<-EOF &&
+		     1	$GIT_AUTHOR_NAME
+		EOF
 		git shortlog -ns HEAD >actual &&
 		test_cmp expect actual
 	)
@@ -281,7 +332,9 @@ test_expect_success 'mailmap.blob defaults to HEAD:.mailmap in bare repo' '
 	git clone --bare non-bare bare &&
 	(
 		cd bare &&
-		echo "     1	Fake Name" >expect &&
+		cat >expect <<-\EOF &&
+		     1	Fake Name
+		EOF
 		git shortlog -ns HEAD >actual &&
 		test_cmp expect actual
 	)
@@ -300,50 +353,46 @@ test_expect_success 'mailmap.blob can handle blobs without trailing newline' '
 	test_cmp expect actual
 '
 
-test_expect_success 'cleanup after mailmap.blob tests' '
-	rm -f .mailmap
-'
-
 test_expect_success 'single-character name' '
-	echo "     1	A <$GIT_AUTHOR_EMAIL>" >expect &&
-	echo "     1	nick1 <bugs@xxxxxxxxxx>" >>expect &&
-	echo "A <$GIT_AUTHOR_EMAIL>" >.mailmap &&
 	test_when_finished "rm .mailmap" &&
+	cat >.mailmap <<-EOF &&
+	A <$GIT_AUTHOR_EMAIL>
+	EOF
+
+	cat >expect <<-EOF &&
+	     1	A <$GIT_AUTHOR_EMAIL>
+	     1	nick1 <bugs@xxxxxxxxxx>
+	EOF
 	git shortlog -es HEAD >actual &&
 	test_cmp expect actual
 '
 
 test_expect_success 'preserve canonical email case' '
-	echo "     1	$GIT_AUTHOR_NAME <AUTHOR@xxxxxxxxxxx>" >expect &&
-	echo "     1	nick1 <bugs@xxxxxxxxxx>" >>expect &&
-	echo "<AUTHOR@xxxxxxxxxxx> <$GIT_AUTHOR_EMAIL>" >.mailmap &&
 	test_when_finished "rm .mailmap" &&
+	cat >.mailmap <<-EOF &&
+	<AUTHOR@xxxxxxxxxxx> <$GIT_AUTHOR_EMAIL>
+	EOF
+
+	cat >expect <<-EOF &&
+	     1	$GIT_AUTHOR_NAME <AUTHOR@xxxxxxxxxxx>
+	     1	nick1 <bugs@xxxxxxxxxx>
+	EOF
 	git shortlog -es HEAD >actual &&
 	test_cmp expect actual
 '
 
-# Extended mailmap configurations should give us the following output for shortlog
-cat >expect << EOF
-$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> (1):
-      initial
-
-CTO <cto@xxxxxxxxxx> (1):
-      seventh
-
-Other Author <other@xxxxxxxxx> (2):
-      third
-      fourth
-
-Santa Claus <santa.claus@xxxxxxxxxxxx> (2):
-      fifth
-      sixth
-
-Some Dude <some@xxxxxxx> (1):
-      second
-
-EOF
-
 test_expect_success 'Shortlog output (complex mapping)' '
+	test_config mailmap.file complex.map &&
+	cat >complex.map <<-EOF &&
+	Committed <$GIT_COMMITTER_EMAIL>
+	<cto@xxxxxxxxxx> <cto@xxxxxxxxxxx>
+	Some Dude <some@xxxxxxx>         nick1 <bugs@xxxxxxxxxx>
+	Other Author <other@xxxxxxxxx>   nick2 <bugs@xxxxxxxxxx>
+	Other Author <other@xxxxxxxxx>         <nick2@xxxxxxxxxx>
+	Santa Claus <santa.claus@xxxxxxxxxxxx> <me@xxxxxxxxxx>
+	Santa Claus <santa.claus@xxxxxxxxxxxx> <me@xxxxxxxxxx>
+	EOF
+
 	echo three >>one &&
 	git add one &&
 	test_tick &&
@@ -369,103 +418,119 @@ test_expect_success 'Shortlog output (complex mapping)' '
 	test_tick &&
 	git commit --author "CTO <cto@xxxxxxxxxxx>" -m seventh &&
 
-	mkdir -p internal_mailmap &&
-	echo "Committed <$GIT_COMMITTER_EMAIL>" > internal_mailmap/.mailmap &&
-	echo "<cto@xxxxxxxxxx>                       <cto@xxxxxxxxxxx>" >> internal_mailmap/.mailmap &&
-	echo "Some Dude <some@xxxxxxx>         nick1 <bugs@xxxxxxxxxx>" >> internal_mailmap/.mailmap &&
-	echo "Other Author <other@xxxxxxxxx>   nick2 <bugs@xxxxxxxxxx>" >> internal_mailmap/.mailmap &&
-	echo "Other Author <other@xxxxxxxxx>         <nick2@xxxxxxxxxx>" >> internal_mailmap/.mailmap &&
-	echo "Santa Claus <santa.claus@xxxxxxxxxxxx> <me@xxxxxxxxxx>" >> internal_mailmap/.mailmap &&
-	echo "Santa Claus <santa.claus@xxxxxxxxxxxx> <me@xxxxxxxxxx>" >> internal_mailmap/.mailmap &&
+	cat >expect <<-EOF &&
+	$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> (1):
+	      initial
+
+	CTO <cto@xxxxxxxxxx> (1):
+	      seventh
+
+	Other Author <other@xxxxxxxxx> (2):
+	      third
+	      fourth
+
+	Santa Claus <santa.claus@xxxxxxxxxxxx> (2):
+	      fifth
+	      sixth
+
+	Some Dude <some@xxxxxxx> (1):
+	      second
+
+	EOF
 
 	git shortlog -e HEAD >actual &&
 	test_cmp expect actual
 
 '
 
-# git log with --pretty format which uses the name and email mailmap placemarkers
-cat >expect << EOF
-Author CTO <cto@xxxxxxxxxxx> maps to CTO <cto@xxxxxxxxxx>
-Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+test_expect_success 'Log output (complex mapping)' '
+	test_config mailmap.file complex.map &&
 
-Author claus <me@xxxxxxxxxx> maps to Santa Claus <santa.claus@xxxxxxxxxxxx>
-Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+	cat >expect <<-EOF &&
+	Author CTO <cto@xxxxxxxxxxx> maps to CTO <cto@xxxxxxxxxx>
+	Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
 
-Author santa <me@xxxxxxxxxx> maps to Santa Claus <santa.claus@xxxxxxxxxxxx>
-Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+	Author claus <me@xxxxxxxxxx> maps to Santa Claus <santa.claus@xxxxxxxxxxxx>
+	Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
 
-Author nick2 <nick2@xxxxxxxxxx> maps to Other Author <other@xxxxxxxxx>
-Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+	Author santa <me@xxxxxxxxxx> maps to Santa Claus <santa.claus@xxxxxxxxxxxx>
+	Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
 
-Author nick2 <bugs@xxxxxxxxxx> maps to Other Author <other@xxxxxxxxx>
-Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+	Author nick2 <nick2@xxxxxxxxxx> maps to Other Author <other@xxxxxxxxx>
+	Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
 
-Author nick1 <bugs@xxxxxxxxxx> maps to Some Dude <some@xxxxxxx>
-Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+	Author nick2 <bugs@xxxxxxxxxx> maps to Other Author <other@xxxxxxxxx>
+	Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
 
-Author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> maps to $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
-Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
-EOF
+	Author nick1 <bugs@xxxxxxxxxx> maps to Some Dude <some@xxxxxxx>
+	Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+
+	Author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> maps to $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
+	Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+	EOF
 
-test_expect_success 'Log output (complex mapping)' '
 	git log --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual &&
 	test_cmp expect actual
 '
 
-cat >expect << EOF
-Author email cto@xxxxxxxxxxx has local-part cto
-Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
+test_expect_success 'Log output (local-part email address)' '
+	cat >expect <<-EOF &&
+	Author email cto@xxxxxxxxxxx has local-part cto
+	Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
 
-Author email me@xxxxxxxxxx has local-part me
-Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
+	Author email me@xxxxxxxxxx has local-part me
+	Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
 
-Author email me@xxxxxxxxxx has local-part me
-Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
+	Author email me@xxxxxxxxxx has local-part me
+	Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
 
-Author email nick2@xxxxxxxxxx has local-part nick2
-Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
+	Author email nick2@xxxxxxxxxx has local-part nick2
+	Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
 
-Author email bugs@xxxxxxxxxx has local-part bugs
-Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
+	Author email bugs@xxxxxxxxxx has local-part bugs
+	Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
 
-Author email bugs@xxxxxxxxxx has local-part bugs
-Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
+	Author email bugs@xxxxxxxxxx has local-part bugs
+	Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
 
-Author email author@xxxxxxxxxxx has local-part author
-Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
-EOF
+	Author email author@xxxxxxxxxxx has local-part author
+	Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
+	EOF
 
-test_expect_success 'Log output (local-part email address)' '
 	git log --pretty=format:"Author email %ae has local-part %al%nCommitter email %ce has local-part %cl%n" >actual &&
 	test_cmp expect actual
 '
 
-cat >expect << EOF
-Author: CTO <cto@xxxxxxxxxx>
-Author: Santa Claus <santa.claus@xxxxxxxxxxxx>
-Author: Santa Claus <santa.claus@xxxxxxxxxxxx>
-Author: Other Author <other@xxxxxxxxx>
-Author: Other Author <other@xxxxxxxxx>
-Author: Some Dude <some@xxxxxxx>
-Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
-EOF
-
 test_expect_success 'Log output with --use-mailmap' '
+	test_config mailmap.file complex.map &&
+
+	cat >expect <<-EOF &&
+	Author: CTO <cto@xxxxxxxxxx>
+	Author: Santa Claus <santa.claus@xxxxxxxxxxxx>
+	Author: Santa Claus <santa.claus@xxxxxxxxxxxx>
+	Author: Other Author <other@xxxxxxxxx>
+	Author: Other Author <other@xxxxxxxxx>
+	Author: Some Dude <some@xxxxxxx>
+	Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
+	EOF
+
 	git log --use-mailmap | grep Author >actual &&
 	test_cmp expect actual
 '
 
-cat >expect << EOF
-Author: CTO <cto@xxxxxxxxxx>
-Author: Santa Claus <santa.claus@xxxxxxxxxxxx>
-Author: Santa Claus <santa.claus@xxxxxxxxxxxx>
-Author: Other Author <other@xxxxxxxxx>
-Author: Other Author <other@xxxxxxxxx>
-Author: Some Dude <some@xxxxxxx>
-Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
-EOF
-
 test_expect_success 'Log output with log.mailmap' '
+	test_config mailmap.file complex.map &&
+
+	cat >expect <<-EOF &&
+	Author: CTO <cto@xxxxxxxxxx>
+	Author: Santa Claus <santa.claus@xxxxxxxxxxxx>
+	Author: Santa Claus <santa.claus@xxxxxxxxxxxx>
+	Author: Other Author <other@xxxxxxxxx>
+	Author: Other Author <other@xxxxxxxxx>
+	Author: Some Dude <some@xxxxxxx>
+	Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
+	EOF
+
 	git -c log.mailmap=True log | grep Author >actual &&
 	test_cmp expect actual
 '
@@ -480,7 +545,7 @@ test_expect_success 'log.mailmap=false disables mailmap' '
 	Author: nick1 <bugs@xxxxxxxxxx>
 	Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
 	EOF
-	git -c log.mailmap=False log | grep Author >actual &&
+	git -c log.mailmap=false log | grep Author >actual &&
 	test_cmp expect actual
 '
 
@@ -498,56 +563,66 @@ test_expect_success '--no-use-mailmap disables mailmap' '
 	test_cmp expect actual
 '
 
-cat >expect <<\EOF
-Author: Santa Claus <santa.claus@xxxxxxxxxxxx>
-Author: Santa Claus <santa.claus@xxxxxxxxxxxx>
-EOF
-
 test_expect_success 'Grep author with --use-mailmap' '
+	test_config mailmap.file complex.map &&
+
+	cat >expect <<-\EOF &&
+	Author: Santa Claus <santa.claus@xxxxxxxxxxxx>
+	Author: Santa Claus <santa.claus@xxxxxxxxxxxx>
+	EOF
 	git log --use-mailmap --author Santa | grep Author >actual &&
 	test_cmp expect actual
 '
-cat >expect <<\EOF
-Author: Santa Claus <santa.claus@xxxxxxxxxxxx>
-Author: Santa Claus <santa.claus@xxxxxxxxxxxx>
-EOF
 
 test_expect_success 'Grep author with log.mailmap' '
+	test_config mailmap.file complex.map &&
+
+	cat >expect <<-\EOF &&
+	Author: Santa Claus <santa.claus@xxxxxxxxxxxx>
+	Author: Santa Claus <santa.claus@xxxxxxxxxxxx>
+	EOF
+
 	git -c log.mailmap=True log --author Santa | grep Author >actual &&
 	test_cmp expect actual
 '
 
 test_expect_success 'log.mailmap is true by default these days' '
+	test_config mailmap.file complex.map &&
 	git log --author Santa | grep Author >actual &&
 	test_cmp expect actual
 '
 
 test_expect_success 'Only grep replaced author with --use-mailmap' '
+	test_config mailmap.file complex.map &&
 	git log --use-mailmap --author "<cto@xxxxxxxxxxx>" >actual &&
 	test_must_be_empty actual
 '
 
-# git blame
-cat >expect <<EOF
-^OBJI ($GIT_AUTHOR_NAME     DATE 1) one
-OBJID (Some Dude    DATE 2) two
-OBJID (Other Author DATE 3) three
-OBJID (Other Author DATE 4) four
-OBJID (Santa Claus  DATE 5) five
-OBJID (Santa Claus  DATE 6) six
-OBJID (CTO          DATE 7) seven
-EOF
 test_expect_success 'Blame output (complex mapping)' '
+	test_config mailmap.file complex.map &&
+
+	cat >expect <<-EOF &&
+	^OBJI ($GIT_AUTHOR_NAME     DATE 1) one
+	OBJID (Some Dude    DATE 2) two
+	OBJID (Other Author DATE 3) three
+	OBJID (Other Author DATE 4) four
+	OBJID (Santa Claus  DATE 5) five
+	OBJID (Santa Claus  DATE 6) six
+	OBJID (CTO          DATE 7) seven
+	EOF
+
 	git blame one >actual &&
 	fuzz_blame actual >actual.fuzz &&
 	test_cmp expect actual.fuzz
 '
 
-cat >expect <<\EOF
-Some Dude <some@xxxxxxx>
-EOF
-
 test_expect_success 'commit --author honors mailmap' '
+	test_config mailmap.file complex.map &&
+
+	cat >expect <<-\EOF &&
+	Some Dude <some@xxxxxxx>
+	EOF
+
 	test_must_fail git commit --author "nick" --allow-empty -meight &&
 	git commit --author "Some Dude" --allow-empty -meight &&
 	git show --pretty=format:"%an <%ae>%n" >actual &&
-- 
2.29.2.222.g5d2a92d10f8





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux