{"thread":{"id":"64224","subject":"git reflog write does not pick up user.name and user.email from config","startedAt":"2025-09-29T11:19:07Z","lastAt":"2025-10-01T16:50:51Z","messageCount":9,"participants":["Michael","Patrick Steinhardt","gitmlko@not-evil.de","git@lohmann.sh","Junio C Hamano","Michael Lohmann"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"527582","messageId":"519E887F-2028-476E-B26D-85E23F7974A5@not-evil.de","threadId":"64224","inReplyTo":null,"subject":"git reflog write does not pick up user.name and user.email from config","fromName":"Michael","fromEmail":"gitmlko@not-evil.de","sentAt":"2025-09-29T11:11:56Z","receivedAt":"2025-09-29T11:19:07Z","isPatch":false,"sender":{"key":"gitmlko@not-evil.de","avatar":null},"body":"Hi there!\n\nI've been playing around with a toy project (an interactive step by step\ngit tutorial that is just a repo) where I have been creating a reflog\nmanually so far. I was happy to see the new `reflog write` feature and\nwanted to integrate it.\n\nWhen comparing the results of my hand made reflog with the new\n`git reflog write` result I found some differences: It does not seem to\npick up the \"user.name\" and \"user.email\" from the local git config.\n\nExample:\n\n```bash\ngit init example && cd example\ngit config --local user.name \"C O Mitter\"\ngit config --local user.email \"committer@example.com\"\n\nmessage=\"hi\"\noid=\"0000000000000000000000000000000000000000\"\n\n# Setting env vars works as expected\nGIT_COMMITTER_NAME=\"$(git config --get user.name)\" \\\n  GIT_COMMITTER_EMAIL=\"$(git config --get user.email)\" \\\n  git reflog write \"refs/test_vars\" \"$oid\" \"$oid\" \"$message\"\n\n# Picking up the information from the local config does not work\nunset GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL\ngit reflog write \"refs/test_no_vars\" \"$oid\" \"$oid\" \"$message\"\n\n# Since setting the env variables to the config value, no diff expected\n# but:\ndiff .git/logs/refs/test_*\n# 1c1\n# < 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 Michael <michael@mycomp.local> 1759142076 +0200\thi\n# ---\n# > 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 C O Mitter <committer@example.com> 1759142076 +0200\thi\n```\n\nIntuitively I would expect these values to be picked up from the local\nconfig instead of having to specify them in env variables. I didn't\nexpect it to fall back to some system values, instead of git config. Is\nthere a reason that this information is not used from the config? And if\nyes, could you set some config, so that it gets picked up?\n\nUnfortunately my ability to understand C is too limited to grasp how\n`git_committer_info` works…\n\nThanks a lot for your work!\nMichael\n\n"},{"id":"527620","messageId":"aNsc9En-DjxVOLcV@pks.im","threadId":"64224","inReplyTo":"519E887F-2028-476E-B26D-85E23F7974A5@not-evil.de","subject":"Re: git reflog write does not pick up user.name and user.email from config","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-09-29T23:57:40Z","receivedAt":"2025-09-29T23:57:47Z","isPatch":false,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi Michael,\n\nOn Mon, Sep 29, 2025 at 01:11:56PM +0200, Michael wrote:\n> Hi there!\n> \n> I've been playing around with a toy project (an interactive step by step\n> git tutorial that is just a repo) where I have been creating a reflog\n> manually so far. I was happy to see the new `reflog write` feature and\n> wanted to integrate it.\n> \n> When comparing the results of my hand made reflog with the new\n> `git reflog write` result I found some differences: It does not seem to\n> pick up the \"user.name\" and \"user.email\" from the local git config.\n> \n> Example:\n> \n> ```bash\n> git init example && cd example\n> git config --local user.name \"C O Mitter\"\n> git config --local user.email \"committer@example.com\"\n> \n> message=\"hi\"\n> oid=\"0000000000000000000000000000000000000000\"\n> \n> # Setting env vars works as expected\n> GIT_COMMITTER_NAME=\"$(git config --get user.name)\" \\\n>   GIT_COMMITTER_EMAIL=\"$(git config --get user.email)\" \\\n>   git reflog write \"refs/test_vars\" \"$oid\" \"$oid\" \"$message\"\n> \n> # Picking up the information from the local config does not work\n> unset GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL\n> git reflog write \"refs/test_no_vars\" \"$oid\" \"$oid\" \"$message\"\n> \n> # Since setting the env variables to the config value, no diff expected\n> # but:\n> diff .git/logs/refs/test_*\n> # 1c1\n> # < 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 Michael <michael@mycomp.local> 1759142076 +0200\thi\n> # ---\n> # > 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 C O Mitter <committer@example.com> 1759142076 +0200\thi\n> ```\n> \n> Intuitively I would expect these values to be picked up from the local\n> config instead of having to specify them in env variables. I didn't\n> expect it to fall back to some system values, instead of git config. Is\n> there a reason that this information is not used from the config? And if\n> yes, could you set some config, so that it gets picked up?\n\nThanks for this great bug report!\n\nYou're definitely onto something. The problem indeed is that we don't\nparse any of the configuration right now, but I agree a 100% that we\nreally should.\n\nThe reason why I never noticed this issue is that our test suite by\ndefault sets both GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL. If set,\nwe'll end up writing those into the reflog as expected. So it's a bit of\na test gap we have.\n\n> Unfortunately my ability to understand C is too limited to grasp how\n> `git_committer_info` works…\n\nYou't typically call it with `repo_config()`. So if you want to work on\nthis, the below should work. Only thing that's missing would be a test\nto verify that the gitconfig is parsed now as well as a proper commit\nmessage to tie it all together.\n\nThanks!\n\nPatrick\n\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex c8f6b93d60..40884787b9 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -422,6 +422,8 @@ static int cmd_reflog_write(int argc, const char **argv, const char *prefix,\n \tif (argc != 4)\n \t\tusage_with_options(reflog_write_usage, options);\n \n+\trepo_config(repo, git_ident_config, NULL);\n+\n \tref = argv[0];\n \tif (!is_root_ref(ref) && check_refname_format(ref, 0))\n \t\tdie(_(\"invalid reference name: %s\"), ref);\n"},{"id":"527623","messageId":"20250930091411.14179-1-gitmlko@not-evil.de","threadId":"64224","inReplyTo":"aNsc9En-DjxVOLcV@pks.im","subject":"[PATCH] builtin/reflog: respect user config in \"write\" subcommand","fromName":"","fromEmail":"gitmlko@not-evil.de","sentAt":"2025-09-30T09:14:11Z","receivedAt":"2025-09-30T09:39:14Z","isPatch":true,"sender":{"key":"gitmlko@not-evil.de","avatar":null},"body":"From: Michael Lohmann <git@lohmann.sh>\n\nPreviously, the reflog write command only recognized the environment\nvariables GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL. It did not account\nfor user.name and user.email settings from the Git configuration.\n\nSince the test suite always sets these variables, it was unnoticed that\nnot present, it would use the system config as defaults instead of the\ngit config.\n\nCo-Authored-By: Patrick Steinhardt <ps@pks.im>\nSigned-off-by: Michael Lohmann <git@lohmann.sh>\n---\n builtin/reflog.c        |  2 ++\n t/t1421-reflog-write.sh | 11 ++++++++++-\n 2 files changed, 12 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex c8f6b93d60..40884787b9 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -422,6 +422,8 @@ static int cmd_reflog_write(int argc, const char **argv, const char *prefix,\n \tif (argc != 4)\n \t\tusage_with_options(reflog_write_usage, options);\n \n+\trepo_config(repo, git_ident_config, NULL);\n+\n \tref = argv[0];\n \tif (!is_root_ref(ref) && check_refname_format(ref, 0))\n \t\tdie(_(\"invalid reference name: %s\"), ref);\ndiff --git a/t/t1421-reflog-write.sh b/t/t1421-reflog-write.sh\nindex 46df64c176..65fc4cae93 100755\n--- a/t/t1421-reflog-write.sh\n+++ b/t/t1421-reflog-write.sh\n@@ -101,10 +101,19 @@ test_expect_success 'simple writes' '\n \t\tEOF\n \n \t\tgit reflog write refs/heads/something $COMMIT_OID $COMMIT_OID second &&\n-\t\ttest_reflog_matches . refs/heads/something <<-EOF\n+\t\ttest_reflog_matches . refs/heads/something <<-EOF &&\n \t\t$ZERO_OID $COMMIT_OID $SIGNATURE\tfirst\n \t\t$COMMIT_OID $COMMIT_OID $SIGNATURE\tsecond\n \t\tEOF\n+\n+\t\tsane_unset GIT_COMMITTER_NAME &&\n+\t\tsane_unset GIT_COMMITTER_EMAIL &&\n+\t\tgit config --local user.name \"Author\" &&\n+\t\tgit config --local user.email \"a@uth.or\" &&\n+\t\tgit reflog write refs/heads/something_new $ZERO_OID $COMMIT_OID first &&\n+\t\ttest_reflog_matches . refs/heads/something_new <<-EOF\n+\t\t$ZERO_OID $COMMIT_OID Author <a@uth.or> 1112911993 -0700\tfirst\n+\t\tEOF\n \t)\n '\n \n\nbase-commit: 821f583da6d30a84249f75f33501504d597bc16b\n-- \n2.51.GIT\n\n"},{"id":"527628","messageId":"aNu-cTrJwPdcW6hq@pks.im","threadId":"64224","inReplyTo":"20250930091411.14179-1-gitmlko@not-evil.de","subject":"Re: [PATCH] builtin/reflog: respect user config in \"write\" subcommand","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-09-30T11:26:41Z","receivedAt":"2025-09-30T11:26:47Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Sep 30, 2025 at 11:14:11AM +0200, gitmlko@not-evil.de wrote:\n> From: Michael Lohmann <git@lohmann.sh>\n\nIs there any specific reason why the originating mail address and the\nauthor information disagree with one another? It makes it hard for us to\nverify that these mail addresses actually map to the same person.\n\n> Previously, the reflog write command only recognized the environment\n> variables GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL. It did not account\n> for user.name and user.email settings from the Git configuration.\n\nNit: we typically write our commit messages in the following style:\n\n  - We describe the problem in the present tense.\n\n  - We then proceed to describe why that problem exists. In our context,\n    it's also relevant to explain why our tests didn't catch the issue.\n\n  - Finally, we use imperative mood to say how the problem is fixed, as\n    if instructing the code to change.\n\nHappy to provide more guidance here as needed.\n\n> Since the test suite always sets these variables, it was unnoticed that\n> not present, it would use the system config as defaults instead of the\n> git config.\n> \n> Co-Authored-By: Patrick Steinhardt <ps@pks.im>\n\nAnother tiny nit: This should be \"Co-authored-by\", with everything\nexcept the leading \"C\" being lower-case.\n\n> diff --git a/t/t1421-reflog-write.sh b/t/t1421-reflog-write.sh\n> index 46df64c176..65fc4cae93 100755\n> --- a/t/t1421-reflog-write.sh\n> +++ b/t/t1421-reflog-write.sh\n> @@ -101,10 +101,19 @@ test_expect_success 'simple writes' '\n>  \t\tEOF\n>  \n>  \t\tgit reflog write refs/heads/something $COMMIT_OID $COMMIT_OID second &&\n> -\t\ttest_reflog_matches . refs/heads/something <<-EOF\n> +\t\ttest_reflog_matches . refs/heads/something <<-EOF &&\n>  \t\t$ZERO_OID $COMMIT_OID $SIGNATURE\tfirst\n>  \t\t$COMMIT_OID $COMMIT_OID $SIGNATURE\tsecond\n>  \t\tEOF\n> +\n> +\t\tsane_unset GIT_COMMITTER_NAME &&\n> +\t\tsane_unset GIT_COMMITTER_EMAIL &&\n> +\t\tgit config --local user.name \"Author\" &&\n> +\t\tgit config --local user.email \"a@uth.or\" &&\n> +\t\tgit reflog write refs/heads/something_new $ZERO_OID $COMMIT_OID first &&\n> +\t\ttest_reflog_matches . refs/heads/something_new <<-EOF\n> +\t\t$ZERO_OID $COMMIT_OID Author <a@uth.or> 1112911993 -0700\tfirst\n> +\t\tEOF\n>  \t)\n>  '\n\nI think it would be preferable to make this a separate test case.\n\nThanks for working on this!\n\nPatrick\n"},{"id":"527635","messageId":"20250930143741.18331-1-git@lohmann.sh","threadId":"64224","inReplyTo":"aNu-cTrJwPdcW6hq@pks.im","subject":"[PATCH v2] builtin/reflog: respect user config in \"write\" subcommand","fromName":"","fromEmail":"git@lohmann.sh","sentAt":"2025-09-30T14:37:41Z","receivedAt":"2025-09-30T14:38:04Z","isPatch":true,"sender":{"key":"git@lohmann.sh","avatar":"https://avatars.githubusercontent.com/u/6929993?v=4"},"body":"From: Michael Lohmann <git@lohmann.sh>\n\nThe reflog write recognizes only GIT_COMMITTER_NAME and\nGIT_COMMITTER_EMAIL environment variables, ignoring the user.name and\nuser.email settings from the Git configuration.\n\nThe test suite sets these variables, so this behavior was unnoticed.\n\nEnsure that the reflog write also uses the values of user.name and\nuser.email if set in the Git configuration.\n\nCo-authored-by: Patrick Steinhardt <ps@pks.im>\nSigned-off-by: Michael Lohmann <git@lohmann.sh>\n---\nThank you for your feedback! Is this better now or how could I improve\nit?\n\nThe reason why I sent it from my other email address was that originally\nI didn't expect to submit a patch. Since I sent the first email from the\nother address, I wasn't sure if it was easier to keep the context, but I\ndidn't have the other perspective. Now sent from the git email.\n\nChange compared to last version:\n- aligned commit message with style guide\n- created a separate test case\n\nMichael\n\n builtin/reflog.c        |  2 ++\n t/t1421-reflog-write.sh | 19 +++++++++++++++++++\n 2 files changed, 21 insertions(+)\n\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex c8f6b93d60..40884787b9 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -422,6 +422,8 @@ static int cmd_reflog_write(int argc, const char **argv, const char *prefix,\n \tif (argc != 4)\n \t\tusage_with_options(reflog_write_usage, options);\n \n+\trepo_config(repo, git_ident_config, NULL);\n+\n \tref = argv[0];\n \tif (!is_root_ref(ref) && check_refname_format(ref, 0))\n \t\tdie(_(\"invalid reference name: %s\"), ref);\ndiff --git a/t/t1421-reflog-write.sh b/t/t1421-reflog-write.sh\nindex 46df64c176..cf0e8608fe 100755\n--- a/t/t1421-reflog-write.sh\n+++ b/t/t1421-reflog-write.sh\n@@ -108,6 +108,25 @@ test_expect_success 'simple writes' '\n \t)\n '\n \n+test_expect_success 'uses user.name and user.email config' '\n+\ttest_when_finished \"rm -rf repo\" &&\n+\tgit init repo &&\n+\t(\n+\t\tcd repo &&\n+\t\ttest_commit initial &&\n+\t\tCOMMIT_OID=$(git rev-parse HEAD) &&\n+\n+\t\tsane_unset GIT_COMMITTER_NAME &&\n+\t\tsane_unset GIT_COMMITTER_EMAIL &&\n+\t\tgit config --local user.name \"Author\" &&\n+\t\tgit config --local user.email \"a@uth.or\" &&\n+\t\tgit reflog write refs/heads/something $ZERO_OID $COMMIT_OID first &&\n+\t\ttest_reflog_matches . refs/heads/something <<-EOF\n+\t\t$ZERO_OID $COMMIT_OID Author <a@uth.or> 1112911993 -0700\tfirst\n+\t\tEOF\n+\t)\n+'\n+\n test_expect_success 'can write to root ref' '\n \ttest_when_finished \"rm -rf repo\" &&\n \tgit init repo &&\n\nbase-commit: 821f583da6d30a84249f75f33501504d597bc16b\n-- \n2.50.1 (Apple Git-155)\n\n"},{"id":"527646","messageId":"xmqqplb750f2.fsf@gitster.g","threadId":"64224","inReplyTo":"20250930143741.18331-1-git@lohmann.sh","subject":"Re: [PATCH v2] builtin/reflog: respect user config in \"write\" subcommand","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-09-30T17:13:05Z","receivedAt":"2025-09-30T17:13:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"git@lohmann.sh writes:\n\n> From: Michael Lohmann <git@lohmann.sh>\n>\n> The reflog write recognizes only GIT_COMMITTER_NAME and\n> GIT_COMMITTER_EMAIL environment variables, ignoring the user.name and\n> user.email settings from the Git configuration.\n\nRephrasing \", ignoring\" and everything after the sentence to\nsomething like\n\n    ..., but forgot to honor the user.name and user.email\n    configuration variables, due to lack of repo_config() call to\n    grab these values from the configuration files.\n\nwould make it more obvious to readers what the right correction\nwould be.\n\n> The test suite sets these variables, so this behavior was unnoticed.\n>\n> Ensure that the reflog write also uses the values of user.name and\n> user.email if set in the Git configuration.\n>\n> Co-authored-by: Patrick Steinhardt <ps@pks.im>\n> Signed-off-by: Michael Lohmann <git@lohmann.sh>\n\nThis is not in general the right place to make repo_config() call,\neven though in the current shape of the program it happens to work.\n\nThis will start to matter once we start adding command line options\nto the program.  We want the configured values read from the\nconfiguration to populate the in-core variables first, and then call\nparse_options() to allow command line arguments to override them.\n\nIn short, move the call above parse_options().\n\nAnother thing to consider is if we want to do this inside\ncmd_reflog(), not here.  Once we add another subcommand that also\nrecords who did what, other than \"write\", to the \"reflog\" command,\nthis starts to matter.\n\n>  \tref = argv[0];\n>  \tif (!is_root_ref(ref) && check_refname_format(ref, 0))\n>  \t\tdie(_(\"invalid reference name: %s\"), ref);\n> diff --git a/t/t1421-reflog-write.sh b/t/t1421-reflog-write.sh\n> index 46df64c176..cf0e8608fe 100755\n> --- a/t/t1421-reflog-write.sh\n> +++ b/t/t1421-reflog-write.sh\n> @@ -108,6 +108,25 @@ test_expect_success 'simple writes' '\n>  \t)\n>  '\n>  \n> +test_expect_success 'uses user.name and user.email config' '\n> +\ttest_when_finished \"rm -rf repo\" &&\n> +\tgit init repo &&\n> +\t(\n> +\t\tcd repo &&\n> +\t\ttest_commit initial &&\n> +\t\tCOMMIT_OID=$(git rev-parse HEAD) &&\n> +\n> +\t\tsane_unset GIT_COMMITTER_NAME &&\n> +\t\tsane_unset GIT_COMMITTER_EMAIL &&\n> +\t\tgit config --local user.name \"Author\" &&\n> +\t\tgit config --local user.email \"a@uth.or\" &&\n> +\t\tgit reflog write refs/heads/something $ZERO_OID $COMMIT_OID first &&\n\nIt certainly is good to test _without_ environment.  Shouldn't we\nalso make sure that _with_ environment variables, these configured\nvalues are overriden with a separate test?\n\n> +\t\ttest_reflog_matches . refs/heads/something <<-EOF\n> +\t\t$ZERO_OID $COMMIT_OID Author <a@uth.or> 1112911993 -0700\tfirst\n\nThis timestamp is from the above \"test_commit\", presumably?  If we\nlater add more tests _before_ this step and they used test_commit,\nwould that screw this test up?  It may make sense to say\n$GIT_COMMITTER_DATE instead of that timestamp here.\n\n> +\t\tEOF\n> +\t)\n> +'\n> +\n>  test_expect_success 'can write to root ref' '\n>  \ttest_when_finished \"rm -rf repo\" &&\n>  \tgit init repo &&\n>\n> base-commit: 821f583da6d30a84249f75f33501504d597bc16b\n\nThanks.\n"},{"id":"527651","messageId":"20250930195320.23825-1-git@lohmann.sh","threadId":"64224","inReplyTo":"xmqqplb750f2.fsf@gitster.g","subject":"[PATCH v3] builtin/reflog: respect user config in \"write\" subcommand","fromName":"Michael Lohmann","fromEmail":"git@lohmann.sh","sentAt":"2025-09-30T19:53:20Z","receivedAt":"2025-09-30T19:54:53Z","isPatch":true,"sender":{"key":"git@lohmann.sh","avatar":"https://avatars.githubusercontent.com/u/6929993?v=4"},"body":"The reflog write recognizes only GIT_COMMITTER_NAME and\nGIT_COMMITTER_EMAIL environment variables, but forgot to honor the\nuser.name and user.email configuration variables, due to lack of\nrepo_config() call to grab these values from the configuration files.\n\nThe test suite sets these variables, so this behavior was unnoticed.\n\nEnsure that the reflog write also uses the values of user.name and\nuser.email if set in the Git configuration.\n\nCo-authored-by: Patrick Steinhardt <ps@pks.im>\nSigned-off-by: Michael Lohmann <git@lohmann.sh>\n---\n- Improved commit message according to Junio Hamanos suggestion\n- moved repo_config() call above parse_options() (I can't judge where\n  the proper place would be)\n- add test to check if env variables overwrite config\n- use $GIT_COMMITTER_DATE instead of that timestamp in existing test\n  case\n\n builtin/reflog.c        |  2 ++\n t/t1421-reflog-write.sh | 36 ++++++++++++++++++++++++++++++++++++\n 2 files changed, 38 insertions(+)\n\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex c8f6b93d60..dcbfe89339 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -418,6 +418,8 @@ static int cmd_reflog_write(int argc, const char **argv, const char *prefix,\n \tconst char *ref, *message;\n \tint ret;\n \n+\trepo_config(repo, git_ident_config, NULL);\n+\n \targc = parse_options(argc, argv, prefix, options, reflog_write_usage, 0);\n \tif (argc != 4)\n \t\tusage_with_options(reflog_write_usage, options);\ndiff --git a/t/t1421-reflog-write.sh b/t/t1421-reflog-write.sh\nindex 46df64c176..603ec3f6ed 100755\n--- a/t/t1421-reflog-write.sh\n+++ b/t/t1421-reflog-write.sh\n@@ -108,6 +108,42 @@ test_expect_success 'simple writes' '\n \t)\n '\n \n+test_expect_success 'uses user.name and user.email config' '\n+\ttest_when_finished \"rm -rf repo\" &&\n+\tgit init repo &&\n+\t(\n+\t\tcd repo &&\n+\t\ttest_commit initial &&\n+\t\tCOMMIT_OID=$(git rev-parse HEAD) &&\n+\n+\t\tsane_unset GIT_COMMITTER_NAME &&\n+\t\tsane_unset GIT_COMMITTER_EMAIL &&\n+\t\tgit config --local user.name \"Author\" &&\n+\t\tgit config --local user.email \"a@uth.or\" &&\n+\t\tgit reflog write refs/heads/something $ZERO_OID $COMMIT_OID first &&\n+\t\ttest_reflog_matches . refs/heads/something <<-EOF\n+\t\t$ZERO_OID $COMMIT_OID Author <a@uth.or> $GIT_COMMITTER_DATE\tfirst\n+\t\tEOF\n+\t)\n+'\n+\n+test_expect_success 'environment variables take precedence over config' '\n+\ttest_when_finished \"rm -rf repo\" &&\n+\tgit init repo &&\n+\t(\n+\t\tcd repo &&\n+\t\ttest_commit initial &&\n+\t\tCOMMIT_OID=$(git rev-parse HEAD) &&\n+\n+\t\tgit config --local user.name \"Author\" &&\n+\t\tgit config --local user.email \"a@uth.or\" &&\n+\t\tgit reflog write refs/heads/something $ZERO_OID $COMMIT_OID first &&\n+\t\ttest_reflog_matches . refs/heads/something <<-EOF\n+\t\t$ZERO_OID $COMMIT_OID $SIGNATURE\tfirst\n+\t\tEOF\n+\t)\n+'\n+\n test_expect_success 'can write to root ref' '\n \ttest_when_finished \"rm -rf repo\" &&\n \tgit init repo &&\n\nbase-commit: 821f583da6d30a84249f75f33501504d597bc16b\n-- \n2.51.0.373.g6d4c29e8d5.dirty\n\n"},{"id":"527673","messageId":"aNzaKAuuzzX1xg6I@pks.im","threadId":"64224","inReplyTo":"20250930195320.23825-1-git@lohmann.sh","subject":"Re: [PATCH v3] builtin/reflog: respect user config in \"write\" subcommand","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-10-01T07:37:12Z","receivedAt":"2025-10-01T07:37:19Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Sep 30, 2025 at 09:53:20PM +0200, Michael Lohmann wrote:\n> The reflog write recognizes only GIT_COMMITTER_NAME and\n> GIT_COMMITTER_EMAIL environment variables, but forgot to honor the\n> user.name and user.email configuration variables, due to lack of\n> repo_config() call to grab these values from the configuration files.\n> \n> The test suite sets these variables, so this behavior was unnoticed.\n> \n> Ensure that the reflog write also uses the values of user.name and\n> user.email if set in the Git configuration.\n> \n> Co-authored-by: Patrick Steinhardt <ps@pks.im>\n> Signed-off-by: Michael Lohmann <git@lohmann.sh>\n\nThanks, this version looks good to me!\n\nPatrick\n"},{"id":"527704","messageId":"xmqqcy7636s7.fsf@gitster.g","threadId":"64224","inReplyTo":"aNzaKAuuzzX1xg6I@pks.im","subject":"Re: [PATCH v3] builtin/reflog: respect user config in \"write\" subcommand","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-10-01T16:50:48Z","receivedAt":"2025-10-01T16:50:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> On Tue, Sep 30, 2025 at 09:53:20PM +0200, Michael Lohmann wrote:\n>> The reflog write recognizes only GIT_COMMITTER_NAME and\n>> GIT_COMMITTER_EMAIL environment variables, but forgot to honor the\n>> user.name and user.email configuration variables, due to lack of\n>> repo_config() call to grab these values from the configuration files.\n>> \n>> The test suite sets these variables, so this behavior was unnoticed.\n>> \n>> Ensure that the reflog write also uses the values of user.name and\n>> user.email if set in the Git configuration.\n>> \n>> Co-authored-by: Patrick Steinhardt <ps@pks.im>\n>> Signed-off-by: Michael Lohmann <git@lohmann.sh>\n>\n> Thanks, this version looks good to me!\n\nYup.  Will apply on top of the ps/reflog-migrate-fixes topic.\n\nI didn't realize \"reflog write\" was so new ;-)\n\nThanks.\n"}]}