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

Re: [PATCH v2 01/17] t0001: allow implicit bare repo discovery for aliased-command test

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 6, 2026, 16:00 UTC
Message-ID
<xmqqse98cc51.fsf@gitster.g>
In-Reply-To
<a1cdbd58f0af27be689230b7d8009d93bc34abca.1775332197.git.gitgitgadget@gmail.com>

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes:

Show 12 quoted lines
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> 8d1a7448206e (setup.c: create `safe.bareRepository`, 2022-07-14)
> introduced a setting to restrict implicit bare repository discovery,
> mitigating a social-engineering attack where an embedded bare repo's
> hooks get executed unknowingly. To allow for that default to change at
> some stage in the future, the tests need to be prepared.
>
> This commit adjusts a test accordingly that runs `git aliasedinit`
> from inside a bare repo to verify that aliased commands work there.
> The test is about alias resolution, not bare repo discovery, so add
> `test_config_global safe.bareRepository all` to opt in explicitly.

Yes, I think most of the tests we run things in a bare repository is not about bare repository discovery but how individual commands behave in a bare repository, and these commands must be kept working even after a future version of Git starts to tighten the rules.

Show 17 quoted lines
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  t/t0001-init.sh | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/t/t0001-init.sh b/t/t0001-init.sh
> index e4d32bb4d2..6bd0a15dac 100755
> --- a/t/t0001-init.sh
> +++ b/t/t0001-init.sh
> @@ -77,6 +77,7 @@ test_expect_success 'plain nested through aliased command' '
>  '
>  
>  test_expect_success 'plain nested in bare through aliased command' '
> +	test_config_global safe.bareRepository all &&
>  	(
>  		git init --bare bare-ancestor-aliased.git &&
>  		cd bare-ancestor-aliased.git &&

So I very much recommend the use of "safe.bareRepository all" in these tests, not in individual test but upfront, just like many tests freeze use of 'main' as the default initial branch name.

I also have to wonder if this alternative patch shouldn't be a better starting point? The idea is that most of the tests that validates how individual operations work in a bare repository are *not* interested in the fact that bare repository access will become opt-in in future version of Git, but they are interested in ensuring that the commands they are testing will keep working as expected when accesses to bare repositories are allowed. So we'll run all existing tests with this in the global config after we set up $HOME for testing. We'll need to write a very few *new* tests to prepare for the default change, and I expect them to explicitly remove the setting from the global config, and checks if the default truly allows or forbids access to a bare repositories. But I am hoping that most of the existing tests shouldn't need changes sprinkled all over.

Thanks.
 t/test-lib.sh | 5 +++++
 1 file changed, 5 insertions(+)
diff --git c/t/test-lib.sh w/t/test-lib.sh
index 70fd3e9baf..fe85a0bf89 100644
--- c/t/test-lib.sh
+++ w/t/test-lib.sh
@@ -1563,6 +1563,11 @@ HOME="$TRASH_DIRECTORY"
 GNUPGHOME="$HOME/gnupg-home-not-used"
 export HOME GNUPGHOME USER_HOME
 
+if test -n "$WITH_BREAKING_CHANGES"
+then
+	git config --global safe.bareRepository all
+fi
+
 # "rm -rf" existing trash directory, even if a previous run left it
 # with bad permissions.
 remove_trash_directory () {
Previous: Johannes Schindelin via GitGitGadgetNext: Johannes Schindelin via GitGitGadget
Message 28 of 44 in “tests: access bare repositories explicitly”
  1. 00/17 tests: access bare repositories explicitlyJohannes Schindelin via GitGitGadget, Apr 2, 2026
  2. 01/17 t0001: allow implicit bare repo discovery for aliased-command testJohannes Schindelin via GitGitGadget, Apr 2, 2026
  3. 02/17 t0001: replace `cd`+`git` with `git --git-dir` in `check_config`Johannes Schindelin via GitGitGadget, Apr 2, 2026
  4. 03/17 t0003: use `--git-dir` for bare repo attribute testsJohannes Schindelin via GitGitGadget, Apr 2, 2026
  5. 04/17 t0056: allow implicit bare repo discovery for `-C` work-tree testsJohannes Schindelin via GitGitGadget, Apr 2, 2026
  6. 05/17 t1020: use `--git-dir` instead of subshell for bare repoJohannes Schindelin via GitGitGadget, Apr 2, 2026
  7. 06/17 t1900: avoid using `-C <dir>` for a bare repositoryJohannes Schindelin via GitGitGadget, Apr 2, 2026
  8. 07/17 t2400: explicitly specify bare repo for `git worktree add`Johannes Schindelin via GitGitGadget, Apr 2, 2026
  9. 08/17 t2406: use `--git-dir=.` for bare repository worktree repairJohannes Schindelin via GitGitGadget, Apr 2, 2026
  10. 09/17 t5503: avoid discovering a bare repositoryJohannes Schindelin via GitGitGadget, Apr 2, 2026
  11. 10/17 t5505: export `GIT_DIR` after `git init --bare`Johannes Schindelin via GitGitGadget, Apr 2, 2026
  12. 11/17 t5509: specify bare repository path explicitlyJohannes Schindelin via GitGitGadget, Apr 2, 2026
  13. Junio C HamanoApr 2, 2026
  14. Johannes SchindelinApr 3, 2026
  15. Junio C HamanoApr 3, 2026
  16. Johannes SchindelinApr 4, 2026
  17. 12/17 t5540/t5541: avoid accessing a bare repository via `-C <dir>`Johannes Schindelin via GitGitGadget, Apr 2, 2026
  18. 13/17 t5619: wrap `test_commit_bulk` in `GIT_DIR` subshell for bare repoJohannes Schindelin via GitGitGadget, Apr 2, 2026
  19. 14/17 t6020: use `-C` for worktree, `--git-dir` for bare repositoryJohannes Schindelin via GitGitGadget, Apr 2, 2026
  20. 15/17 t9210: pass `safe.bareRepository=all` to `scalar register`Johannes Schindelin via GitGitGadget, Apr 2, 2026
  21. 16/17 t9700: stop relying on implicit bare repo discoveryJohannes Schindelin via GitGitGadget, Apr 2, 2026
  22. 17/17 git p4 clone --bare: need to be explicit about the gitdirJohannes Schindelin via GitGitGadget, Apr 2, 2026
  23. Junio C HamanoApr 2, 2026
  24. Johannes SchindelinApr 4, 2026
  25. Junio C HamanoApr 6, 2026
  26. 00/17 tests: access bare repositories explicitlyJohannes Schindelin via GitGitGadget, Apr 4, 2026
  27. 01/17 t0001: allow implicit bare repo discovery for aliased-command testJohannes Schindelin via GitGitGadget, Apr 4, 2026
  28. Junio C HamanoApr 6, 2026
  29. 02/17 t0001: replace `cd`+`git` with `git --git-dir` in `check_config`Johannes Schindelin via GitGitGadget, Apr 4, 2026
  30. 03/17 t0003: use `--git-dir` for bare repo attribute testsJohannes Schindelin via GitGitGadget, Apr 4, 2026
  31. 04/17 t0056: allow implicit bare repo discovery for `-C` work-tree testsJohannes Schindelin via GitGitGadget, Apr 4, 2026
  32. 05/17 t1020: use `--git-dir` instead of subshell for bare repoJohannes Schindelin via GitGitGadget, Apr 4, 2026
  33. 06/17 t1900: avoid using `-C <dir>` for a bare repositoryJohannes Schindelin via GitGitGadget, Apr 4, 2026
  34. 07/17 t2400: explicitly specify bare repo for `git worktree add`Johannes Schindelin via GitGitGadget, Apr 4, 2026
  35. 08/17 t2406: use `--git-dir=.` for bare repository worktree repairJohannes Schindelin via GitGitGadget, Apr 4, 2026
  36. 09/17 t5503: avoid discovering a bare repositoryJohannes Schindelin via GitGitGadget, Apr 4, 2026
  37. 10/17 t5505: export `GIT_DIR` after `git init --bare`Johannes Schindelin via GitGitGadget, Apr 4, 2026
  38. 11/17 t5509: specify bare repository path explicitlyJohannes Schindelin via GitGitGadget, Apr 4, 2026
  39. 12/17 t5540/t5541: avoid accessing a bare repository via `-C <dir>`Johannes Schindelin via GitGitGadget, Apr 4, 2026
  40. 13/17 t5619: wrap `test_commit_bulk` in `GIT_DIR` subshell for bare repoJohannes Schindelin via GitGitGadget, Apr 4, 2026
  41. 14/17 t6020: use `-C` for worktree, `--git-dir` for bare repositoryJohannes Schindelin via GitGitGadget, Apr 4, 2026
  42. 15/17 t9210: pass `safe.bareRepository=all` to `scalar register`Johannes Schindelin via GitGitGadget, Apr 4, 2026
  43. 16/17 t9700: stop relying on implicit bare repo discoveryJohannes Schindelin via GitGitGadget, Apr 4, 2026
  44. 17/17 git p4 clone --bare: need to be explicit about the gitdirJohannes Schindelin via GitGitGadget, Apr 4, 2026

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.