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

From: Patrick Steinhardt <[email-masked]>
Date: Tue, 30 Sep 2025 13:26:41 +0200

On Tue, Sep 30, 2025 at 11:14:11AM +0200, [email-masked] wrote:
> From: Michael Lohmann <[email-masked]>

Is there any specific reason why the originating mail address and the
author information disagree with one another? It makes it hard for us to
verify that these mail addresses actually map to the same person.

> 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.

Nit: we typically write our commit messages in the following style:

  - We describe the problem in the present tense.

  - We then proceed to describe why that problem exists. In our context,
    it's also relevant to explain why our tests didn't catch the issue.

  - Finally, we use imperative mood to say how the problem is fixed, as
    if instructing the code to change.

Happy to provide more guidance here as needed.

> 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 <[email-masked]>

Another tiny nit: This should be "Co-authored-by", with everything
except the leading "C" being lower-case.

> 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 "[email-masked]" &&
> +		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 <[email-masked]> 1112911993 -0700	first
> +		EOF
>  	)
>  '

I think it would be preferable to make this a separate test case.

Thanks for working on this!

Patrick