Skip to content

Commit 1c2d052

Browse files
John Caigitster
authored andcommitted
setup: initialize is_bare_cfg
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8c9a952 commit 1c2d052

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

setup.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,7 @@ static int check_repository_format_gently(const char *gitdir, struct repository_
741741

742742
if (verify_repository_format(candidate, &err) < 0) {
743743
if (nongit_ok) {
744+
the_repository->is_bare_cfg = 1;
744745
warning("%s", err.buf);
745746
strbuf_release(&err);
746747
*nongit_ok = -1;
@@ -1017,6 +1018,7 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
10171018
if (nongit_ok) {
10181019
*nongit_ok = 1;
10191020
free(gitfile);
1021+
the_repository->is_bare_cfg = 0;
10201022
return NULL;
10211023
}
10221024
die(_("not a git repository: '%s'"), gitdirenv);
@@ -1069,6 +1071,7 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
10691071

10701072
/* set_git_work_tree() must have been called by now */
10711073
worktree = repo_get_work_tree(the_repository);
1074+
the_repository->is_bare_cfg = 0;
10721075

10731076
/* both repo_get_work_tree() and cwd are already normalized */
10741077
if (!strcmp(cwd->buf, worktree)) { /* cwd == worktree */
@@ -1125,6 +1128,9 @@ static const char *setup_discovered_git_dir(const char *gitdir,
11251128

11261129
/* #0, #1, #5, #8, #9, #12, #13 */
11271130
set_git_work_tree(".");
1131+
1132+
if (the_repository->is_bare_cfg < 0)
1133+
the_repository->is_bare_cfg = 0;
11281134
if (strcmp(gitdir, DEFAULT_GIT_DIR_ENVIRONMENT))
11291135
set_git_dir(gitdir, 0);
11301136
inside_git_dir = 0;
@@ -1767,6 +1773,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
17671773
die(_("not a git repository (or any of the parent directories): %s"),
17681774
DEFAULT_GIT_DIR_ENVIRONMENT);
17691775
*nongit_ok = 1;
1776+
the_repository->is_bare_cfg = 1;
17701777
break;
17711778
case GIT_DIR_HIT_MOUNT_POINT:
17721779
if (!nongit_ok)

0 commit comments

Comments
 (0)