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

Re: [PATCH 2/3] t0033-safe-directory: check when 'safe.directory' is ignored

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 29, 2022, 17:57 UTC
Message-ID
<xmqq8rrndb6h.fsf@gitster.g>
In-Reply-To
<a44b4f0e-038c-9bcd-80d6-f53c87bd7f2d@github.com>
Derrick Stolee <derrickstolee@github.com> writes:
Show 49 quoted lines
> On 4/27/2022 4:37 PM, Junio C Hamano wrote:
>> SZEDER Gábor <szeder.dev@gmail.com> writes:
>> 
>>> According to the documentation 'safe.directory' "is only respected
>>> when specified in a system or global config, not when it is specified
>>> in a repository config or via the command line option -c
>>> safe.directory=<path>".
>>>
>>> Add tests to check that 'safe.directory' in the repository config or
>>> on the command line is indeed ignored.
>>>
>>> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
>>> ---
>>>  t/t0033-safe-directory.sh | 13 +++++++++++++
>>>  1 file changed, 13 insertions(+)
>>>
>>> diff --git a/t/t0033-safe-directory.sh b/t/t0033-safe-directory.sh
>>> index 6f9680e8b0..82dac0eb93 100755
>>> --- a/t/t0033-safe-directory.sh
>>> +++ b/t/t0033-safe-directory.sh
>>> @@ -16,6 +16,19 @@ test_expect_success 'safe.directory is not set' '
>>>  	expect_rejected_dir
>>>  '
>>>  
>>> +test_expect_success 'ignoring safe.directory on the command line' '
>>> +	test_must_fail git -c safe.directory="$(pwd)" status 2>err &&
>>> +	grep "unsafe repository" err
>>> +'
>>> +
>>> +test_expect_success 'ignoring safe.directory in repo config' '
>>> +	(
>>> +		unset GIT_TEST_ASSUME_DIFFERENT_OWNER &&
>>> +		git config safe.directory "$(pwd)"
>>> +	) &&
>>> +	expect_rejected_dir
>>> +'
>> 
>> I am debating myself if we want to remove the in-repository
>> safe.directory configuration setting after this test piece is done,
>> with test_when_finished.  We just made sure, with this test, that
>> having the variable does not affect anything, so the subsequent
>> tests should not care hence it is probably OK.  On the other hand,
>> to make sure those settings they make (e.g. setting it globally is
>> what the next test we can see below does) is what affects their
>> outcome, it removes one more thing we need to worry about if we
>> clean after ourselves.  I dunno.
>
> test_config would do the same, right? I think it automatically
> does the test_when_finished for us.

I thought it (specifically, anything depends on test_when_finished) has trouble working well from inside a subprocess?

Previous: Derrick StoleeNext: SZEDER Gábor
Message 25 of 39 in “Updates to the safe.directory config option”
  1. 0/3 Updates to the safe.directory config optionDerrick Stolee via GitGitGadget, Apr 13, 2022
  2. 1/3 t0033: add tests for safe.directoryDerrick Stolee via GitGitGadget, Apr 13, 2022
  3. Junio C HamanoApr 13, 2022
  4. Derrick StoleeApr 13, 2022
  5. Ævar Arnfjörð BjarmasonApr 13, 2022
  6. Junio C HamanoApr 13, 2022
  7. Derrick StoleeApr 13, 2022
  8. 2/3 setup: fix safe.directory key not being checkedMatheus Valadares via GitGitGadget, Apr 13, 2022
  9. Junio C HamanoApr 13, 2022
  10. 3/3 setup: opt-out of check with safe.directory=*Derrick Stolee via GitGitGadget, Apr 13, 2022
  11. Junio C HamanoApr 13, 2022
  12. Junio C HamanoApr 13, 2022
  13. Derrick StoleeApr 13, 2022
  14. Junio C HamanoApr 13, 2022
  15. Junio C HamanoApr 13, 2022
  16. Taylor BlauApr 13, 2022
  17. Junio C HamanoApr 13, 2022
  18. 0/3 t0033-safe-directory: test improvements and a documentation clarificationSZEDER Gábor, Apr 27, 2022
  19. 1/3 t0033-safe-directory: check the error message without matching the trash dirSZEDER Gábor, Apr 27, 2022
  20. Taylor BlauMay 9, 2022
  21. Carlo Marcelo Arenas BelónMay 10, 2022
  22. 2/3 t0033-safe-directory: check when 'safe.directory' is ignoredSZEDER Gábor, Apr 27, 2022
  23. Junio C HamanoApr 27, 2022
  24. Derrick StoleeApr 29, 2022
  25. Junio C HamanoApr 29, 2022
  26. SZEDER GáborApr 29, 2022
  27. Derrick StoleeApr 29, 2022
  28. SZEDER GáborMay 10, 2022
  29. Taylor BlauMay 10, 2022
  30. Carlo Marcelo Arenas BelónMay 10, 2022
  31. Taylor BlauMay 10, 2022
  32. Eric SunshineMay 10, 2022
  33. 3/3 safe.directory: document and check that it's ignored in the environmentSZEDER Gábor, Apr 27, 2022
  34. Junio C HamanoApr 27, 2022
  35. Junio C HamanoApr 27, 2022
  36. Derrick StoleeApr 29, 2022
  37. SZEDER GáborMay 9, 2022
  38. Junio C HamanoMay 9, 2022
  39. SZEDER GáborMay 10, 2022

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.