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

[PATCH v6 1/2] ident: test how GIT_* and user.{name,email} interact

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Feb 5, 2019, 19:52 UTC
Message-ID
<20190205195212.25550-2-avarab@gmail.com>
In-Reply-To
<20190204184850.10040-1-williamh@gentoo.org>

There were no explicit tests for the interaction between setting GIT_* in the environment, and the user.{name,email} config variables. These tests are basic, but we're about to learn {author,committer}.{name,email} in addition to user.{name,email}, so they'll soon become more useful.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t7517-per-repo-email.sh | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
diff --git a/t/t7517-per-repo-email.sh b/t/t7517-per-repo-email.sh
index 231b8cc19d..84bd9e89e5 100755
--- a/t/t7517-per-repo-email.sh
+++ b/t/t7517-per-repo-email.sh
@@ -85,4 +85,38 @@ test_expect_success REBASE_P \
 	test_must_fail git rebase -p master
 '
 
+test_expect_success 'fallbacks for GIT_* and user.{name,email}' '
+	# We must have committer in the object
+	test_must_fail test_env \
+		GIT_AUTHOR_NAME=author.name \
+		GIT_AUTHOR_EMAIL=author@email \
+		GIT_COMMITTER_NAME= \
+		GIT_COMMITTER_EMAIL= \
+		test_commit A 2>stderr &&
+	test_i18ngrep "empty ident name.*not allowed" stderr &&
+
+	# With no committer E-Mail we will have an empty field
+	test_env \
+		GIT_AUTHOR_NAME=author.name \
+		GIT_AUTHOR_EMAIL=author@email \
+		GIT_COMMITTER_NAME=committer.name \
+		GIT_COMMITTER_EMAIL= \
+		test_commit B 2>stderr &&
+	echo "author.name author@email committer.name " >expected &&
+	git log --format="%an %ae %cn %ce" -1 >actual &&
+	test_cmp expected actual &&
+
+	# Environment overrides config
+	test_config user.name author.config.name &&
+	test_env \
+		GIT_AUTHOR_NAME=author.name \
+		GIT_AUTHOR_EMAIL=author@email \
+		GIT_COMMITTER_NAME=committer.name \
+		GIT_COMMITTER_EMAIL= \
+		test_commit C 2>stderr &&
+	echo "author.name author@email committer.name " >expected &&
+	git log --format="%an %ae %cn %ce" -1 >actual &&
+	test_cmp expected actual
+'
+
 test_done
-- 
2.20.1.611.gfbb209baf1
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 6 of 23 in “config: allow giving separate author and committer”
  1. 0/1 config: allow giving separate author and committerWilliam Hubbs, Feb 4, 2019
  2. 1/1 config: allow giving separate author and committer identsWilliam Hubbs, Feb 4, 2019
  3. Johannes SchindelinFeb 5, 2019
  4. Junio C HamanoFeb 5, 2019
  5. 0/2 New {author,committer}.{name,email} configÆvar Arnfjörð Bjarmason, Feb 5, 2019
  6. 1/2 ident: test how GIT_* and user.{name,email} interactÆvar Arnfjörð Bjarmason, Feb 5, 2019
  7. 2/2 config: allow giving separate author and committer identsÆvar Arnfjörð Bjarmason, Feb 5, 2019
  8. Junio C HamanoFeb 5, 2019
  9. Ævar Arnfjörð BjarmasonFeb 5, 2019
  10. William HubbsFeb 6, 2019
  11. William HubbsFeb 6, 2019
  12. William HubbsFeb 6, 2019
  13. Junio C HamanoFeb 6, 2019
  14. William HubbsFeb 13, 2019
  15. Junio C HamanoFeb 13, 2019
  16. William HubbsFeb 14, 2019
  17. Ævar Arnfjörð BjarmasonFeb 6, 2019
  18. Ævar Arnfjörð BjarmasonFeb 6, 2019
  19. Jeff KingFeb 6, 2019
  20. William HubbsFeb 6, 2019
  21. Junio C HamanoFeb 6, 2019
  22. William HubbsFeb 6, 2019
  23. Derrick StoleeApr 15, 2019

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.