Skip to content

Commit 2819ac8

Browse files
committed
Merge branch 'jc/move-is-bare-repository-cfg-variable-to-repo' into seen
Code rewrite to turn the is_bare_repository_cfg global variable into a member in the the_repo singleton repository object. * jc/move-is-bare-repository-cfg-variable-to-repo: repository: BUG when is_bare_cfg is not initialized setup: initialize is_bare_cfg git: remove is_bare_repository_cfg global variable
2 parents 7d1656f + 8771214 commit 2819ac8

29 files changed

+80
-56
lines changed

attr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ static enum git_attr_direction direction;
681681

682682
void git_attr_set_direction(enum git_attr_direction new_direction)
683683
{
684-
if (is_bare_repository() && new_direction != GIT_ATTR_INDEX)
684+
if (repo_is_bare(the_repository) && new_direction != GIT_ATTR_INDEX)
685685
BUG("non-INDEX attr direction in a bare repo");
686686

687687
if (new_direction != direction)
@@ -848,7 +848,7 @@ static struct attr_stack *read_attr(struct index_state *istate,
848848
res = read_attr_from_index(istate, path, flags);
849849
} else if (tree_oid) {
850850
res = read_attr_from_blob(istate, tree_oid, path, flags);
851-
} else if (!is_bare_repository()) {
851+
} else if (!repo_is_bare(the_repository)) {
852852
if (direction == GIT_ATTR_CHECKOUT) {
853853
res = read_attr_from_index(istate, path, flags);
854854
if (!res)

builtin/bisect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
707707
struct object_id oid;
708708
const char *head;
709709

710-
if (is_bare_repository())
710+
if (repo_is_bare(the_repository))
711711
no_checkout = 1;
712712

713713
/*

builtin/blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ int cmd_blame(int argc,
10991099

11001100
revs.disable_stdin = 1;
11011101
setup_revisions(argc, argv, &revs, NULL);
1102-
if (!revs.pending.nr && is_bare_repository()) {
1102+
if (!revs.pending.nr && repo_is_bare(the_repository)) {
11031103
struct commit *head_commit;
11041104
struct object_id head_oid;
11051105

builtin/check-attr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ int cmd_check_attr(int argc,
116116
struct object_id initialized_oid;
117117
int cnt, i, doubledash, filei;
118118

119-
if (!is_bare_repository())
119+
if (!repo_is_bare(the_repository))
120120
setup_work_tree();
121121

122122
git_config(git_default_config, NULL);

builtin/clone.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,7 @@ int cmd_clone(int argc,
14181418
repo_clear(the_repository);
14191419

14201420
/* At this point, we need the_repository to match the cloned repo. */
1421-
if (repo_init(the_repository, git_dir, work_tree))
1421+
if (repo_init(the_repository, git_dir, work_tree, -1))
14221422
warning(_("failed to initialize the repo, skipping bundle URI"));
14231423
else if (fetch_bundle_uri(the_repository, bundle_uri, &has_heuristic))
14241424
warning(_("failed to fetch objects from bundle URI '%s'"),
@@ -1449,7 +1449,7 @@ int cmd_clone(int argc,
14491449
repo_clear(the_repository);
14501450

14511451
/* At this point, we need the_repository to match the cloned repo. */
1452-
if (repo_init(the_repository, git_dir, work_tree))
1452+
if (repo_init(the_repository, git_dir, work_tree, -1))
14531453
warning(_("failed to initialize the repo, skipping bundle URI"));
14541454
else if (fetch_bundle_list(the_repository,
14551455
transport->bundles))

builtin/fetch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1655,7 +1655,7 @@ static int set_head(const struct ref *remote_refs, int follow_remote_head,
16551655

16561656
if (!head_name)
16571657
goto cleanup;
1658-
is_bare = is_bare_repository();
1658+
is_bare = repo_is_bare(the_repository);
16591659
create_only = follow_remote_head == FOLLOW_REMOTE_ALWAYS ? 0 : !is_bare;
16601660
if (is_bare) {
16611661
strbuf_addstr(&b_head, "HEAD");

builtin/gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ struct repository *repo UNUSED)
725725
die(_("failed to parse gc.logExpiry value %s"), cfg.gc_log_expire);
726726

727727
if (cfg.pack_refs < 0)
728-
cfg.pack_refs = !is_bare_repository();
728+
cfg.pack_refs = !repo_is_bare(the_repository);
729729

730730
argc = parse_options(argc, argv, prefix, builtin_gc_options,
731731
builtin_gc_usage, 0);

builtin/init-db.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ int cmd_init_db(int argc,
9191
const struct option init_db_options[] = {
9292
OPT_STRING(0, "template", &template_dir, N_("template-directory"),
9393
N_("directory from which templates will be used")),
94-
OPT_SET_INT(0, "bare", &is_bare_repository_cfg,
94+
OPT_SET_INT(0, "bare", &the_repository->is_bare_cfg,
9595
N_("create a bare repository"), 1),
9696
{ OPTION_CALLBACK, 0, "shared", &init_shared_repository,
9797
N_("permissions"),
@@ -112,7 +112,7 @@ int cmd_init_db(int argc,
112112

113113
argc = parse_options(argc, argv, prefix, init_db_options, init_db_usage, 0);
114114

115-
if (real_git_dir && is_bare_repository_cfg == 1)
115+
if (real_git_dir && the_repository->is_bare_cfg == 1)
116116
die(_("options '%s' and '%s' cannot be used together"), "--separate-git-dir", "--bare");
117117

118118
if (real_git_dir && !is_absolute_path(real_git_dir))
@@ -156,7 +156,7 @@ int cmd_init_db(int argc,
156156
} else if (0 < argc) {
157157
usage(init_db_usage[0]);
158158
}
159-
if (is_bare_repository_cfg == 1) {
159+
if (the_repository->is_bare_cfg == 1) {
160160
char *cwd = xgetcwd();
161161
setenv(GIT_DIR_ENVIRONMENT, cwd, argc > 0);
162162
free(cwd);
@@ -183,7 +183,7 @@ int cmd_init_db(int argc,
183183
*/
184184
git_dir = xstrdup_or_null(getenv(GIT_DIR_ENVIRONMENT));
185185
work_tree = xstrdup_or_null(getenv(GIT_WORK_TREE_ENVIRONMENT));
186-
if ((!git_dir || is_bare_repository_cfg == 1) && work_tree)
186+
if ((!git_dir || the_repository->is_bare_cfg == 1) && work_tree)
187187
die(_("%s (or --work-tree=<directory>) not allowed without "
188188
"specifying %s (or --git-dir=<directory>)"),
189189
GIT_WORK_TREE_ENVIRONMENT,
@@ -220,10 +220,10 @@ int cmd_init_db(int argc,
220220
strbuf_release(&sb);
221221
}
222222

223-
if (is_bare_repository_cfg < 0)
224-
is_bare_repository_cfg = guess_repository_type(git_dir);
223+
if (the_repository->is_bare_cfg < 0)
224+
the_repository->is_bare_cfg = guess_repository_type(git_dir);
225225

226-
if (!is_bare_repository_cfg) {
226+
if (!the_repository->is_bare_cfg) {
227227
const char *git_dir_parent = strrchr(git_dir, '/');
228228
if (git_dir_parent) {
229229
char *rel = xstrndup(git_dir, git_dir_parent - git_dir);

builtin/repack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ int cmd_repack(int argc,
12751275

12761276
if (write_bitmaps < 0) {
12771277
if (!write_midx &&
1278-
(!(pack_everything & ALL_INTO_ONE) || !is_bare_repository()))
1278+
(!(pack_everything & ALL_INTO_ONE) || !repo_is_bare(the_repository)))
12791279
write_bitmaps = 0;
12801280
}
12811281
if (pack_kept_objects < 0)

builtin/reset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ int cmd_reset(int argc,
450450
if (reset_type != SOFT && (reset_type != MIXED || repo_get_work_tree(the_repository)))
451451
setup_work_tree();
452452

453-
if (reset_type == MIXED && is_bare_repository())
453+
if (reset_type == MIXED && repo_is_bare(the_repository))
454454
die(_("%s reset is not allowed in a bare repository"),
455455
_(reset_type_names[reset_type]));
456456

0 commit comments

Comments
 (0)