Skip to content

safe.bareRepository: default to "explicit" with WITH_BREAKING_CHANGES

Johannes Schindelin via GitGitGadget git 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest8 patches 0 repliesNew
  2. v18 patches 1 replySuperseded

Changes in v2 from the cover letter

* Made it compatible with Patrick Steinhardt's set -e work.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8test-lib: allow bare repository access when breaking changes are enabledt/test-lib.sh+13 -00 replies
2/8t7900: do not let `$HOME/.gitconfig` interfere with XDG testst/t7900-maintenance.sh+10 -20 replies
3/8t1300: remove global config settings injected by test-lib.sht/t1300-config.sh+7 -00 replies
4/8t1305: use `--git-dir=.` for bare repo in include cycle testt/t1305-config-include.sh+2 -20 replies
5/8t5601: restore `.gitconfig` after includeIf testt/t5601-clone.sh+3 -10 replies
6/8ls-files tests: filter `.gitconfig` from `--others` outputt/t3000-ls-files-others.sh t/t3001-ls-files-others-exclude.sh t/t3002-ls-files-dashpath.sh +4 more+21 -20 replies
7/8status tests: filter `.gitconfig` from status outputt/t7060-wtstatus.sh t/t7061-wtstatus-ignore.sh t/t7064-wtstatus-pv2.sh +2 more+34 -20 replies
8/8safe.bareRepository: default to "explicit" with WITH_BREAKING_CHANGESDocumentation/BreakingChanges.adoc Documentation/config/safe.adoc setup.c +1 more+44 -40 replies

Reviews trailers per patch

None of the 8 patches has a Reviewed-by or Acked-by.

PatchJunio C Hamano
SeriesOriginal-patch-by
1/8Original-patch-by
2/8
3/8
4/8
5/8
6/8
7/8
8/8

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/8] safe.bareRepository: default to "explicit" with WITH_BREAKING_CHANGES

This supersedes my earlier series [*1*] which took the approach of adjusting individual tests to access bare repositories explicitly.

As Junio suggested [*2*], this series instead takes the approach of setting safe.bareRepository=all in the test environment's global config whenever WITH_BREAKING_CHANGES is in effect, so that existing tests continue to work without individual modifications.

Implementing this turned out to require a number of follow-up adjustments, because writing to $HOME/.gitconfig has side effects beyond the intended
setting: $HOME is the trash directory, which doubles as the test repository's working tree, so the file shows up in ls-files and status output, and tests that manipulate $HOME/.gitconfig for their own purposes can clobber or remove the setting. Patches 2 through 7 address these interactions in the affected test scripts.

The final patch flips the safe.bareRepository default to "explicit" under WITH_BREAKING_CHANGES.

Footnote [*1*]:
https://lore.kernel.org/git/[email protected]/

Footnote [*2*]: https://lore.kernel.org/git/[email protected]/

Changes since v1:

* Made it compatible with Patrick Steinhardt's set -e work.

Johannes Schindelin (8):
test-lib: allow bare repository access when breaking changes are
enabled
t7900: do not let $HOME/.gitconfig interfere with XDG tests
t1300: remove global config settings injected by test-lib.sh
t1305: use --git-dir=. for bare repo in include cycle test
t5601: restore .gitconfig after includeIf test
ls-files tests: filter .gitconfig from --others output status tests: filter .gitconfig from status output safe.bareRepository: default to "explicit" with WITH_BREAKING_CHANGES

 Documentation/BreakingChanges.adoc            | 24 +++++++++++++++++
 Documentation/config/safe.adoc                | 10 +++++--
 setup.c                                       |  4 +++
 t/t0035-safe-bare-repository.sh               | 10 +++++--
 t/t1300-config.sh                             |  7 +++++
 t/t1305-config-include.sh                     |  4 +--
 t/t3000-ls-files-others.sh                    |  4 +++
 t/t3001-ls-files-others-exclude.sh            |  3 +++
 t/t3002-ls-files-dashpath.sh                  |  2 ++
 t/t3009-ls-files-others-nonsubmodule.sh       |  1 +
 ...common-prefixes-and-directory-traversal.sh |  3 ++-
 t/t5601-clone.sh                              |  4 ++-
 t/t7060-wtstatus.sh                           |  3 +--
 t/t7061-wtstatus-ignore.sh                    | 27 +++++++++++++++++++
 t/t7064-wtstatus-pv2.sh                       |  1 +
 t/t7104-reset-hard.sh                         |  2 +-
 t/t7508-status.sh                             |  4 +++
 t/t7521-ignored-mode.sh                       |  1 +
 t/t7900-maintenance.sh                        | 12 +++++++--
 t/test-lib-functions.sh                       |  8 ++++++
 t/test-lib.sh                                 | 13 +++++++++
 21 files changed, 134 insertions(+), 13 deletions(-)

base-commit: 94f057755b7941b321fd11fec1b2e3ca5313a4e0
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2098%2Fdscho%2Fsafe-bare-repo-default-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2098/dscho/safe-bare-repo-default-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/2098

Range-diff vs v1:

1: 62707b4109 ! 1: 179fcf5369 test-lib: allow bare repository access when breaking changes are enabled
@@ Commit message
--exclude-standard or git status --ignored; those are addressed
by subsequent commits.

+ The .git/info/exclude write is guarded by test -d .git/info
+ rather than using mkdir -p, because some tests (e.g. t0008)
+ expect to create .git/info/ themselves and would fail with
+ Patrick Steinhardt's set -e preparation (ps/test-set-e-clean) if
+ the directory already existed. For tests using TEST_NO_CREATE_REPO
+ (where no .git/ exists at all), the guard also handles that case.
+
[1] https://lore.kernel.org/git/[email protected]/

@@ t/test-lib.sh: cd -P "$TRASH_DIRECTORY" || BAIL_OUT "cannot cd -P to \"$TRASH_DI
+if test -n "$WITH_BREAKING_CHANGES"
+then
+ git config --global safe.bareRepository all &&
-+ echo "/.gitconfig" >>.git/info/exclude
++ # Only write to .git/info/exclude when the directory exists
++ # (i.e. when git init created the repo). If we mkdir -p it
++ # ourselves, tests that expect to create .git/info/ themselves
++ # (e.g. t0008) would fail.
++ if test -d .git/info
++ then
++ echo "/.gitconfig" >>.git/info/exclude
++ fi
+fi
+
start_test_output "$0"

 2:  d9a2e76f3c = 2:  4dc5151e59 t7900: do not let `$HOME/.gitconfig` interfere with XDG tests
 3:  9c10e72eed = 3:  7d68155805 t1300: remove global config settings injected by test-lib.sh
 4:  092ec11621 = 4:  5ff48e0892 t1305: use `--git-dir=.` for bare repo in include cycle test
 5:  3aca302275 = 5:  ed7294ace3 t5601: restore `.gitconfig` after includeIf test
 6:  ef57244778 = 6:  556db0eabe ls-files tests: filter `.gitconfig` from `--others` output
 7:  56fe902644 = 7:  ac4da79eac status tests: filter `.gitconfig` from status output
 8:  64db45e385 = 8:  73bb1aa171 safe.bareRepository: default to "explicit" with WITH_BREAKING_CHANGES
Signature · 1 line
gitgitgadget