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

[PATCH] builtin/reflog: respect user config in "write" subcommand

From
Ggitmlko@not-evil.de <gitmlko@not-evil.de>
Date
Sep 30, 2025, 09:14 UTC
Message-ID
<20250930091411.14179-1-gitmlko@not-evil.de>
In-Reply-To
<aNsc9En-DjxVOLcV@pks.im>
From: Michael Lohmann <git@lohmann.sh>

Previously, the reflog write command only recognized the environment variables GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL. It did not account for user.name and user.email settings from the Git configuration.

Since the test suite always sets these variables, it was unnoticed that not present, it would use the system config as defaults instead of the git config.

Co-Authored-By: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Michael Lohmann <git@lohmann.sh>
---
 builtin/reflog.c        |  2 ++
 t/t1421-reflog-write.sh | 11 ++++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/builtin/reflog.c b/builtin/reflog.c
index c8f6b93d60..40884787b9 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -422,6 +422,8 @@ static int cmd_reflog_write(int argc, const char **argv, const char *prefix,
 	if (argc != 4)
 		usage_with_options(reflog_write_usage, options);
 
+	repo_config(repo, git_ident_config, NULL);
+
 	ref = argv[0];
 	if (!is_root_ref(ref) && check_refname_format(ref, 0))
 		die(_("invalid reference name: %s"), ref);
diff --git a/t/t1421-reflog-write.sh b/t/t1421-reflog-write.sh
index 46df64c176..65fc4cae93 100755
--- a/t/t1421-reflog-write.sh
+++ b/t/t1421-reflog-write.sh
@@ -101,10 +101,19 @@ test_expect_success 'simple writes' '
 		EOF
 
 		git reflog write refs/heads/something $COMMIT_OID $COMMIT_OID second &&
-		test_reflog_matches . refs/heads/something <<-EOF
+		test_reflog_matches . refs/heads/something <<-EOF &&
 		$ZERO_OID $COMMIT_OID $SIGNATURE	first
 		$COMMIT_OID $COMMIT_OID $SIGNATURE	second
 		EOF
+
+		sane_unset GIT_COMMITTER_NAME &&
+		sane_unset GIT_COMMITTER_EMAIL &&
+		git config --local user.name "Author" &&
+		git config --local user.email "a@uth.or" &&
+		git reflog write refs/heads/something_new $ZERO_OID $COMMIT_OID first &&
+		test_reflog_matches . refs/heads/something_new <<-EOF
+		$ZERO_OID $COMMIT_OID Author <a@uth.or> 1112911993 -0700	first
+		EOF
 	)
 '
 

base-commit: 821f583da6d30a84249f75f33501504d597bc16b
-- 
2.51.GIT
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 3 of 9 in “git reflog write does not pick up user.name and user.email from config”
  1. MichaelSep 29, 2025
  2. Patrick SteinhardtSep 29, 2025
  3. builtin/reflog: respect user config in "write" subcommandgitmlko@not-evil.de, Sep 30, 2025
  4. Patrick SteinhardtSep 30, 2025
  5. builtin/reflog: respect user config in "write" subcommandgit@lohmann.sh, Sep 30, 2025
  6. Junio C HamanoSep 30, 2025
  7. builtin/reflog: respect user config in "write" subcommandMichael Lohmann, Sep 30, 2025
  8. Patrick SteinhardtOct 1, 2025
  9. Junio C HamanoOct 1, 2025

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.