diff mbox series

[3/3] repository: BUG when is_bare_cfg is not initialized

Message ID 749ba7f52086f2b444a9e073c431d7d4f4c7204e.1730926082.git.gitgitgadget@gmail.com (mailing list archive)
State New
Headers show
Series Remove is_bare_repository_cfg global state | expand

Commit Message

John Cai Nov. 6, 2024, 8:48 p.m. UTC
From: John Cai <jcai@gitlab.com>

The is_bare_cfg member of the repository struct should be properly
initiated when setting up a repository. BUG when repo_is_bare() sees
that the flag has not been set.

Signed-off-by: John Cai <johncai86@gmail.com>
---
 repository.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/repository.c b/repository.c
index 96608058b61..cd1d59ea1b9 100644
--- a/repository.c
+++ b/repository.c
@@ -464,5 +464,7 @@  int repo_hold_locked_index(struct repository *repo,
 int repo_is_bare(struct repository *repo)
 {
 	/* if core.bare is not 'false', let's see if there is a work tree */
+	if (repo->is_bare_cfg < 0 )
+		BUG("is_bare_cfg unspecified");
 	return repo->is_bare_cfg && !repo_get_work_tree(repo);
 }