Skip to content

Commit a8bf3c0

Browse files
committed
Merge branch 'kl/allow-working-in-dot-git-in-non-bare-repository'
The "disable repository discovery of a bare repository" check, triggered by setting safe.bareRepository configuration variable to 'explicit', has been loosened to exclude the ".git/" directory inside a non-bare repository from the check. So you can do "cd .git && git cmd" to run a Git command that works on a bare repository without explicitly specifying $GIT_DIR now. * kl/allow-working-in-dot-git-in-non-bare-repository: setup: allow cwd=.git w/ bareRepository=explicit
2 parents fa50e7a + 45bb916 commit a8bf3c0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

setup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,8 @@ static enum discovery_result setup_git_directory_gently_1(struct strbuf *dir,
13711371

13721372
if (is_git_directory(dir->buf)) {
13731373
trace2_data_string("setup", NULL, "implicit-bare-repository", dir->buf);
1374-
if (get_allowed_bare_repo() == ALLOWED_BARE_REPO_EXPLICIT)
1374+
if (get_allowed_bare_repo() == ALLOWED_BARE_REPO_EXPLICIT &&
1375+
!ends_with_path_components(dir->buf, ".git"))
13751376
return GIT_DIR_DISALLOWED_BARE;
13761377
if (!ensure_valid_ownership(NULL, NULL, dir->buf, report))
13771378
return GIT_DIR_INVALID_OWNERSHIP;

t/t0035-safe-bare-repository.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,12 @@ test_expect_success 'no trace when GIT_DIR is explicitly provided' '
7878
expect_accepted_explicit "$pwd/outer-repo/bare-repo"
7979
'
8080

81+
test_expect_success 'no trace when "bare repository" is .git' '
82+
expect_accepted_implicit -C outer-repo/.git
83+
'
84+
85+
test_expect_success 'no trace when "bare repository" is a subdir of .git' '
86+
expect_accepted_implicit -C outer-repo/.git/objects
87+
'
88+
8189
test_done

0 commit comments

Comments
 (0)