Skip to content

Commit c7964c2

Browse files
tiennoupks-t
authored andcommitted
repository: being a worktree means we're not really bare
We were previously conflating any error into GIT_ENOTFOUND, which might or might not be correct. This fixes the code so a config error is bubbled up, as well as preserving the semantics in the face of worktree-repositories
1 parent a572323 commit c7964c2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/repository.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,15 @@ static int load_config_data(git_repository *repo, const git_config *config)
268268
{
269269
int is_bare;
270270

271+
int err = git_config_get_bool(&is_bare, config, "core.bare");
272+
if (err < 0 && err != GIT_ENOTFOUND)
273+
return err;
274+
271275
/* Try to figure out if it's bare, default to non-bare if it's not set */
272-
if (git_config_get_bool(&is_bare, config, "core.bare") < 0)
273-
repo->is_bare = 0;
276+
if (err != GIT_ENOTFOUND)
277+
repo->is_bare = is_bare && !repo->is_worktree;
274278
else
275-
repo->is_bare = is_bare;
279+
repo->is_bare = 0;
276280

277281
return 0;
278282
}

0 commit comments

Comments
 (0)