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

Re: [PATCH v2 1/2] [Outreachy] t3903-stash: test without configured user.name and user.email

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 16, 2018, 05:55 UTC
Message-ID
<xmqqsh01k1mr.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20181114222524.2624-1-slawica92@hotmail.com>
Slavica Djukic <slavicadj.ip2018@gmail.com> writes:
> +test_expect_failure 'stash works when user.name and user.email are not set' '
> +	git reset &&
> +	git var GIT_COMMITTER_IDENT >expected &&

All the other existing test pieces in this file calls the expected result "expect"; is there a reason why this patch needs to be different (e.g. 'expect' file left by the earlier step needs to be kept unmodified for later use, or something like that)? If not, please avoid making a difference in irrelevant details, as that would waste time of readers by forcing them to guess if there is such a reason that readers cannot immediately see.

Anyway, we grab the committer ident we use by default during the test with this command. OK.

> +	>1 &&
> +	git add 1 &&
> +	git stash &&
And we make sure we can create stash.
> +	git var GIT_COMMITTER_IDENT >actual &&
> +	test_cmp expected actual &&

I am not sure what you are testing with this step. There is nothing that changed environment variables or configuration since we ran "git var" above. Why does this test suspect that somebody in the future may break the expectation that after running 'git add' and/or 'git stash', our committer identity may have been changed, and how would such a breakage happen?

> +	>2 &&
> +	git add 2 &&
> +	test_config user.useconfigonly true &&
> +	test_config stash.usebuiltin true &&

Now we start using use-config-only, so unsetting environment variables will cause trouble when Git insists on having an explicitly configured identities. Makes sense.

Show 7 quoted lines
> +	(
> +		sane_unset GIT_AUTHOR_NAME &&
> +		sane_unset GIT_AUTHOR_EMAIL &&
> +		sane_unset GIT_COMMITTER_NAME &&
> +		sane_unset GIT_COMMITTER_EMAIL &&
> +		test_unconfig user.email &&
> +		test_unconfig user.name &&

And then we try the same test, but without environment or config. Since we are unsetting the environment, in order to be nice for future test writers, we do this in a subshell, so that we do not have to restore the original values of environment variables.

Don't we need to be nice the same way for configuration variables, though? We _know_ that nobody sets user.{email,name} config up to this point in the test sequence, so that is why we do not do a "save before test and then restore to the original" dance on them. Even though we are relying on the fact that these two variables are left unset in the configuration file, we unconfig them here anyway, and I do think it is a good idea for documentation purposes (i.e. we are not documenting what we assume the config before running this test would be; we are documenting what state we want these two variables are in when running this "git stash"---that is, they are both unset).

So these later part of this test piece makes sense. I still do not know what you wanted to check in the earlier part of the test, though.

Show 5 quoted lines
> +		git stash
> +	)
> +'
> +
>  test_done
Previous: Johannes SchindelinNext: Junio C Hamano
Message 31 of 41 in “[Outreachy] t3903-stash: test without configured user name”
  1. 1/3 [Outreachy] t3903-stash: test without configured user nameSlavica, Oct 23, 2018
  2. Christian CouderOct 23, 2018
  3. SlavicaOct 24, 2018
  4. Junio C HamanoOct 25, 2018
  5. Eric SunshineOct 23, 2018
  6. Junio C HamanoOct 24, 2018
  7. Johannes SchindelinOct 24, 2018
  8. Junio C HamanoOct 24, 2018
  9. Johannes SchindelinOct 24, 2018
  10. Junio C HamanoOct 25, 2018
  11. 1/3 [Outreachy] t3903-stash: test without configured user nameSlavica Djukic, Oct 24, 2018
  12. 1/3 [Outreachy] t3903-stash: test without configured user nameSlavica Djukic, Oct 24, 2018
  13. Eric SunshineOct 24, 2018
  14. Junio C HamanoOct 25, 2018
  15. 1/3 [Outreachy] t3903-stash: test without configured user nameSlavica Djukic, Oct 25, 2018
  16. 1/3 [Outreachy] t3903-stash: test without configured user nameSlavica Djukic, Oct 25, 2018
  17. Junio C HamanoOct 26, 2018
  18. Slavica DjukicOct 30, 2018
  19. 0/3 [Outreachy] make stash work if user.name and user.email are not configuredSlavica Djukic, Nov 1, 2018
  20. 1/3 [Outreachy] t3903-stash: test without configured user.name and user.emailSlavica Djukic, Nov 1, 2018
  21. Christian CouderNov 1, 2018
  22. 3/3 stash: tolerate missing user identityJunio C Hamano, Nov 2, 2018
  23. 2/3 [Outreachy] ident: introduce set_fallback_ident() functionSlavica Djukic, Nov 1, 2018
  24. Junio C HamanoNov 2, 2018
  25. Junio C HamanoNov 2, 2018
  26. Junio C HamanoNov 2, 2018
  27. 3/3 [Outreachy] stash: use set_fallback_ident() functionSlavica Djukic, Nov 1, 2018
  28. 0/2 [Outreachy] make stash work if user.name and user.email are not configuredSlavica Djukic, Nov 14, 2018
  29. 1/2 [Outreachy] t3903-stash: test without configured user.name and user.emailSlavica Djukic, Nov 14, 2018
  30. Johannes SchindelinNov 15, 2018
  31. Junio C HamanoNov 16, 2018
  32. Junio C HamanoNov 16, 2018
  33. Junio C HamanoNov 16, 2018
  34. Slavica DjukicNov 16, 2018
  35. Junio C HamanoNov 16, 2018
  36. Slavica DjukicNov 17, 2018
  37. Junio C HamanoNov 18, 2018
  38. 2/2 [Outreachy] stash: tolerate missing user identitySlavica Djukic, Nov 14, 2018
  39. Junio C HamanoNov 16, 2018
  40. 0/1 make stash work if user.name and user.email are not configuredSlavica Djukic, Nov 18, 2018
  41. 1/1 stash: tolerate missing user identitySlavica Djukic, Nov 18, 2018

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.