[PATCH 3/3] repository: BUG when is_bare_cfg is not initialized
- From
John Cai via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Nov 6, 2024, 20:48 UTC
- Message-ID
- <749ba7f52086f2b444a9e073c431d7d4f4c7204e.1730926082.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.1826.git.git.1730926082.gitgitgadget@gmail.com>
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 --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); }
-- gitgitgadget