Skip to content

Commit 269a0bf

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 ab3c5b5 + 8771214 commit 269a0bf

29 files changed

+80
-56
lines changed

attr.c

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

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

686686
if (new_direction != direction)
@@ -847,7 +847,7 @@ static struct attr_stack *read_attr(struct index_state *istate,
847847
res = read_attr_from_index(istate, path, flags);
848848
} else if (tree_oid) {
849849
res = read_attr_from_blob(istate, tree_oid, path, flags);
850-
} else if (!is_bare_repository()) {
850+
} else if (!repo_is_bare(the_repository)) {
851851
if (direction == GIT_ATTR_CHECKOUT) {
852852
res = read_attr_from_index(istate, path, flags);
853853
if (!res)

builtin/bisect.c

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

708-
if (is_bare_repository())
708+
if (repo_is_bare(the_repository))
709709
no_checkout = 1;
710710

711711
/*

builtin/blame.c

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

10931093
revs.disable_stdin = 1;
10941094
setup_revisions(argc, argv, &revs, NULL);
1095-
if (!revs.pending.nr && is_bare_repository()) {
1095+
if (!revs.pending.nr && repo_is_bare(the_repository)) {
10961096
struct commit *head_commit;
10971097
struct object_id head_oid;
10981098

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
@@ -1415,7 +1415,7 @@ int cmd_clone(int argc,
14151415
repo_clear(the_repository);
14161416

14171417
/* At this point, we need the_repository to match the cloned repo. */
1418-
if (repo_init(the_repository, git_dir, work_tree))
1418+
if (repo_init(the_repository, git_dir, work_tree, -1))
14191419
warning(_("failed to initialize the repo, skipping bundle URI"));
14201420
else if (fetch_bundle_uri(the_repository, bundle_uri, &has_heuristic))
14211421
warning(_("failed to fetch objects from bundle URI '%s'"),
@@ -1446,7 +1446,7 @@ int cmd_clone(int argc,
14461446
repo_clear(the_repository);
14471447

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

builtin/fetch.c

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

16411641
if (!head_name)
16421642
goto cleanup;
1643-
is_bare = is_bare_repository();
1643+
is_bare = repo_is_bare(the_repository);
16441644
create_only = follow_remote_head == FOLLOW_REMOTE_ALWAYS ? 0 : !is_bare;
16451645
if (is_bare) {
16461646
strbuf_addstr(&b_head, "HEAD");

builtin/gc.c

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

724724
if (cfg.pack_refs < 0)
725-
cfg.pack_refs = !is_bare_repository();
725+
cfg.pack_refs = !repo_is_bare(the_repository);
726726

727727
argc = parse_options(argc, argv, prefix, builtin_gc_options,
728728
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
@@ -1273,7 +1273,7 @@ int cmd_repack(int argc,
12731273

12741274
if (write_bitmaps < 0) {
12751275
if (!write_midx &&
1276-
(!(pack_everything & ALL_INTO_ONE) || !is_bare_repository()))
1276+
(!(pack_everything & ALL_INTO_ONE) || !repo_is_bare(the_repository)))
12771277
write_bitmaps = 0;
12781278
}
12791279
if (pack_kept_objects < 0)

builtin/reset.c

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

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

0 commit comments

Comments
 (0)