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

Re: [PATCH 00/17] tests: access bare repositories explicitly

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 6, 2026, 15:45 UTC
Message-ID
<xmqq1pgsdrdw.fsf@gitster.g>
In-Reply-To
<dcb8c6f1-1410-9f04-c389-6f69ac4fe842@gmx.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 9 quoted lines
>> Shoudln't there be a patch [01/18] before everything else that
>> updates Documentation/BreakingChanges.adoc to propose the default
>> change?
>
> Well, yes and no. There should be an update to BreakingChanges to propose
> that default change, but obviously it should not only be a documentation
> change: It should also adjust `Documentation/config/safe.adoc` to mention
> the intended change of behavior, and it should introduce
> `WITH_BREAKING_HANGES`-specific conditional code in `setup.c`.
Ah, very true.

And of course we'd need some tests conditional to breaking-changes prerequisite in the meantime, to make sure that the default is to allow "all" before breaking changes, and with the prereq the test checks the new behaviour is to deny by default.

As to the changes to existing tests (i.e., this patch series started doing), they have a bit of balancing act.

 * Most importantly, they need to make sure their indivial
   operations, when working on a bare repository is allowed in any
   unspecified means, continue to behave sensibly.  "git log -p" in
   a bare repository should still produce patches, "git bisect" in a
   bare repository should work and assume --no-checkout, etc.
 * Then all of them would need to be somehow told that working on a
   bare repository is allowed in suitable way.  For most of then it
   should be done by setting safe.bareRepository in the global
   scope, just like many tests specify the default branch name
   upfront just once (this is a tangent, but we should find a way to
   get rid of GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME variable support
   in our binary and instead set it up in the test environment's
   ~/.gitconfig), some may add --git-dir=., etc.  But the primary
   focus with this change is to preserve what individual operation
   each test wants to validate (see above).
 * There may need to be some tests behind the WITH_BREAKING_CHANGES
   prerequisite that makes sure that the access to the repository is
   blocked without the configuration loosening the condition, but
   they hopefully would be minimum---unlike "how this particular
   command should operate in a bare repository?" that vary per
   command, "no command should work in a bare repository unless ..."
   that is enforced in the setup phase do not have to validate each
   and every command.
Show 7 quoted lines
> And, crucially, it should pass the test suite under WITH_BREAKING_CHANGES.
>
> To do that, a lot more needs to happen than just the 17 patches in this
> here patch series. Most of the additional changes are quite mechanical,
> and can be validated relatively easily despite their sheer number. And
> only at the very end of those changes can that `safe.bareRepository`
> change even be proposed.

I agree with all the flow you propose here. And for that process, I think the early parts of the effort (i.e., there ~20 patches) that prepare existing tests that make sure the operations of individual commands in bare repositories should be kept to bare minimum by freezing the world to allow bare repositories, just like initial branch names are frozen to either 'master' or 'main' in many test scripts. Adding "--git-dir=." (regardless of the "-C there") you proposed in the other thread is a valid way (but it may be tedious to do and verify); doing "git config --global safe.bareRepository all" upfront, if it works, might be simpler. Any approach that would achieve what we want is fine.

> I plan on proposing that patch in due time, to start the discussion
> whether or not it is a good idea to change the default of
> `safe.bareRepository` in Git 3.0.

Yup, I do not think it is a bad thing in the longer term, even though I suspect it might be a bit more disruptive than others we have in the breaking changes document.

Thanks for working on this.
Previous: Johannes SchindelinNext: Johannes Schindelin via GitGitGadget
Message 25 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.