Skip to content

Loosening safe.bareRepository=explicit even further

Junio C Hamano git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2setup: detect to be in $GIT_DIR with a new helpersetup.c+6 -10 replies
2/2setup: make bareRepository=explicit work in GIT_DIR of a secondary worktreesetup.c t/t0035-safe-bare-repository.sh+58 -27 replies

Reviews trailers per patch

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

PatchKyle LippincottKyle Meyer
SeriesHelped-by Helped-by
1/2
2/2

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

Read the v1 thread

Cover letter [PATCH 0/2] Loosening safe.bareRepository=explicit even further

Earlier 45bb9162 (setup: allow cwd=.git w/ bareRepository=explicit, 2024-01-20) loosened safe.bareRepository=explicit in such a way that working inside the ".git/" directory (or its subdirectories) of a repository that is not bare can be done without an explicit GIT_DIR or "git --git-dir=<path>". The code needed for its change was almost trivial---when it looks like we encountered a bare repository, if the last path component of the discovered "$GIT_DIR" is ".git", then it cannot be anything but the $GIT_DIR of a non-bare repository, the root of whose working tree is the parent directory of that ".git" directory. This is because projects cannot create a ".git" directory in their working tree and cause clone/checkout to extract them in the victim's working tree.

This almost works, until somebody starts using "git worktree add" to create a secondary worktree. Their $GIT_DIR resides inside the $GIT_DIR of the primary worktree of the same repository, at $GIT_DIR/worktree/$name where $name is the name of the secondary worktree, which is not ".git".

These two patches are to extend the "if you can work in its working tree, you should be able to work in its $GIT_DIR" for secondary worktrees.

Junio C Hamano (2):
setup: detect to be in $GIT_DIR with a new helper
setup: make bareRepository=explicit work in GIT_DIR of a secondary worktree

 setup.c                         | 57 ++++++++++++++++++++++++++++++++-
 t/t0035-safe-bare-repository.sh |  8 ++++-
 2 files changed, 63 insertions(+), 2 deletions(-)
Signature · 1 line
2.44.0-165-ge09f1254c5