git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Cc: Kyle Lippincott <spectral@google.com>, Glen Choo <glencbz@gmail.com>
Subject: [PATCH 0/2] Loosening safe.bareRepository=explicit even further
Date: Fri,  8 Mar 2024 13:19:55 -0800	[thread overview]
Message-ID: <20240308211957.3758770-1-gitster@pobox.com> (raw)
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


  reply	other threads:[~2024-03-08 21:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-20  0:08 [PATCH] setup: allow cwd=.git w/ bareRepository=explicit Kyle Lippincott via GitGitGadget
2024-01-20 22:26 ` Junio C Hamano
2024-01-22 20:50   ` Kyle Lippincott
2024-03-06 17:27 ` Junio C Hamano
2024-03-08 21:19   ` Junio C Hamano [this message]
2024-03-08 21:19     ` [PATCH 1/2] setup: detect to be in $GIT_DIR with a new helper Junio C Hamano
2024-03-08 21:19     ` [PATCH 2/2] setup: make bareRepository=explicit work in GIT_DIR of a secondary worktree Junio C Hamano
2024-03-08 22:30       ` Junio C Hamano
2024-03-08 23:10       ` Kyle Lippincott
2024-03-08 23:32         ` Junio C Hamano
2024-03-09  0:12           ` Kyle Lippincott
2024-03-09  1:14             ` Junio C Hamano
2024-03-09  3:20       ` Kyle Meyer
2024-03-09  5:53         ` Junio C Hamano
2024-03-09 23:27     ` [PATCH v2] setup: notice more types of implicit bare repositories Junio C Hamano
2024-03-11 19:23       ` Kyle Lippincott
2024-03-11 21:02         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240308211957.3758770-1-gitster@pobox.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=glencbz@gmail.com \
    --cc=spectral@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).