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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 8, 2024, 21:19 UTC
Message-ID
<20240308211957.3758770-1-gitster@pobox.com>
In-Reply-To
<xmqqv85zqniu.fsf@gitster.g>

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(-)
-- 
2.44.0-165-ge09f1254c5
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 17 in “setup: allow cwd=.git w/ bareRepository=explicit”
  1. setup: allow cwd=.git w/ bareRepository=explicitKyle Lippincott via GitGitGadget, Jan 20, 2024
  2. Junio C HamanoJan 20, 2024
  3. Kyle LippincottJan 22, 2024
  4. Junio C HamanoMar 6, 2024
  5. 0/2 Loosening safe.bareRepository=explicit even furtherJunio C Hamano, Mar 8, 2024
  6. 2/2 setup: make bareRepository=explicit work in GIT_DIR of a secondary worktreeJunio C Hamano, Mar 8, 2024
  7. Junio C HamanoMar 8, 2024
  8. Kyle LippincottMar 8, 2024
  9. Junio C HamanoMar 8, 2024
  10. Kyle LippincottMar 9, 2024
  11. Junio C HamanoMar 9, 2024
  12. Kyle MeyerMar 9, 2024
  13. Junio C HamanoMar 9, 2024
  14. 1/2 setup: detect to be in $GIT_DIR with a new helperJunio C Hamano, Mar 8, 2024
  15. setup: notice more types of implicit bare repositoriesJunio C Hamano, Mar 9, 2024
  16. Kyle LippincottMar 11, 2024
  17. Junio C HamanoMar 11, 2024

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.