From: "John Cai via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: John Cai <johncai86@gmail.com>, John Cai <jcai@gitlab.com>
Subject: [PATCH 2/3] setup: initialize is_bare_cfg
Date: Wed, 06 Nov 2024 20:48:01 +0000 [thread overview]
Message-ID: <19c97feb06ef2f01f89b462678fe304b58fcba37.1730926082.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1826.git.git.1730926082.gitgitgadget@gmail.com>
From: John Cai <jcai@gitlab.com>
A subsequent commit will BUG() when the is_bare_cfg member is
uninitialized. Since there are still some codepaths that initializing the
is_bare_cfg variable, initialize them.
Signed-off-by: John Cai <johncai86@gmail.com>
---
setup.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/setup.c b/setup.c
index 6bc4aef3a8b..5680976c598 100644
--- a/setup.c
+++ b/setup.c
@@ -741,6 +741,7 @@ static int check_repository_format_gently(const char *gitdir, struct repository_
if (verify_repository_format(candidate, &err) < 0) {
if (nongit_ok) {
+ the_repository->is_bare_cfg = 1;
warning("%s", err.buf);
strbuf_release(&err);
*nongit_ok = -1;
@@ -1017,6 +1018,7 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
if (nongit_ok) {
*nongit_ok = 1;
free(gitfile);
+ the_repository->is_bare_cfg = 0;
return NULL;
}
die(_("not a git repository: '%s'"), gitdirenv);
@@ -1069,6 +1071,7 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
/* set_git_work_tree() must have been called by now */
worktree = repo_get_work_tree(the_repository);
+ the_repository->is_bare_cfg = 0;
/* both repo_get_work_tree() and cwd are already normalized */
if (!strcmp(cwd->buf, worktree)) { /* cwd == worktree */
@@ -1125,6 +1128,9 @@ static const char *setup_discovered_git_dir(const char *gitdir,
/* #0, #1, #5, #8, #9, #12, #13 */
set_git_work_tree(".");
+
+ if (the_repository->is_bare_cfg < 0)
+ the_repository->is_bare_cfg = 0;
if (strcmp(gitdir, DEFAULT_GIT_DIR_ENVIRONMENT))
set_git_dir(gitdir, 0);
inside_git_dir = 0;
@@ -1767,6 +1773,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
die(_("not a git repository (or any of the parent directories): %s"),
DEFAULT_GIT_DIR_ENVIRONMENT);
*nongit_ok = 1;
+ the_repository->is_bare_cfg = 1;
break;
case GIT_DIR_HIT_MOUNT_POINT:
if (!nongit_ok)
--
gitgitgadget
next prev parent reply other threads:[~2024-11-06 20:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-06 20:47 [PATCH 0/3] Remove is_bare_repository_cfg global state John Cai via GitGitGadget
2024-11-06 20:48 ` [PATCH 1/3] git: remove is_bare_repository_cfg global variable John Cai via GitGitGadget
2024-11-07 5:46 ` Junio C Hamano
2024-11-07 16:04 ` shejialuo
2024-11-08 1:24 ` Junio C Hamano
2024-11-16 12:09 ` shejialuo
2024-11-06 20:48 ` John Cai via GitGitGadget [this message]
2024-11-07 6:25 ` [PATCH 2/3] setup: initialize is_bare_cfg Junio C Hamano
2024-11-06 20:48 ` [PATCH 3/3] repository: BUG when is_bare_cfg is not initialized John Cai via GitGitGadget
2024-11-26 8:08 ` [PATCH 0/3] Remove is_bare_repository_cfg global state Junio C Hamano
2024-12-11 23:09 ` (RFH Windows breakage) " 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=19c97feb06ef2f01f89b462678fe304b58fcba37.1730926082.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=jcai@gitlab.com \
--cc=johncai86@gmail.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).