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

Re: [PATCH v2 2/2] tests: add test for separate author and committer idents

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jan 25, 2019, 23:05 UTC
Message-ID
<875zuc49uj.fsf@evledraar.gmail.com>
In-Reply-To
<20190125215955.30032-3-williamh@gentoo.org>
On Fri, Jan 25 2019, William Hubbs wrote:
Show 12 quoted lines
> Signed-off-by: William Hubbs <williamh@gentoo.org>
> ---
>  t/t7517-per-repo-email.sh | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/t/t7517-per-repo-email.sh b/t/t7517-per-repo-email.sh
> index 231b8cc19d..06c7c0fb78 100755
> --- a/t/t7517-per-repo-email.sh
> +++ b/t/t7517-per-repo-email.sh
> @@ -85,4 +85,21 @@ test_expect_success REBASE_P \
>  	test_must_fail git rebase -p master
>  '

Let's include this in the main patch. We don't split up tests into their own patches like this.

> +test_expect_success \
> +	'author and committer config settings override user config settings' '

This can just be on one line. We're not strict about 79 characters in tests.

> +	sane_unset GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL &&
> +	sane_unset GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL &&
Fine, but FYI sets these variables for the rest of the test.

But more importantly there should be a test for how the various override interactions between the config & env variables work. I.e. whether GIT_COMMITTER_NAME set in the env will override "user.email" etc.

Show 6 quoted lines
> +	git config user.name user &&
> +	git config user.email user@example.com &&
> +	git config author.name author &&
> +	git config author.email author@example.com &&
> +	git config committer.name committer &&
> +	git config committer.email committer@example.com &&
This should use "test_config" so it'll be unset after this test.
Show 5 quoted lines
> +	test_commit config-names &&
> +	[ "$(git log --format=%an -1)" = "author" ] &&
> +	[ "$(git log --format=%ae -1)" = "author@example.com" ] &&
> +	[ "$(git log --format=%cn -1)" = "committer" ] &&
> +	[ "$(git log --format=%ce -1)" = "committer@example.com" ]

Should use something like test_cmp so that on failure we see what the difference is. I'd just do:

    cat >expected <<EOF... &&
    git log --format="an:%an%nae:%ae[...]" -1 >actual &&
    test_cmp ...
> +'
> +
>  test_done
Previous: William HubbsNext: William Hubbs
Message 11 of 15 in “Add author and committer configuration settings”
  1. William HubbsJan 25, 2019
  2. 1/2 config: allow giving separate author and committer identsWilliam Hubbs, Jan 25, 2019
  3. Ævar Arnfjörð BjarmasonJan 25, 2019
  4. William HubbsJan 28, 2019
  5. Junio C HamanoJan 28, 2019
  6. Ævar Arnfjörð BjarmasonJan 28, 2019
  7. Junio C HamanoJan 28, 2019
  8. William HubbsJan 28, 2019
  9. William HubbsJan 29, 2019
  10. 2/2 tests: add test for separate author and committer identsWilliam Hubbs, Jan 25, 2019
  11. Ævar Arnfjörð BjarmasonJan 25, 2019
  12. William HubbsJan 26, 2019
  13. Ævar Arnfjörð BjarmasonJan 26, 2019
  14. Eric SunshineJan 27, 2019
  15. Ævar Arnfjörð BjarmasonJan 28, 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.