Skip to content

Commit f638992

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 08c83f2 + 8771214 commit f638992

29 files changed

+81
-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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,8 @@ static int set_head(const struct ref *remote_refs)
16291629
else
16301630
head_name = xstrdup(heads.items[0].string);
16311631
if (head_name) {
1632-
int is_bare = is_bare_repository();
1632+
int is_bare = repo_is_bare(the_repository);
1633+
16331634
if (is_bare) {
16341635
strbuf_addstr(&b_head, "HEAD");
16351636
strbuf_addf(&b_remote_head, "refs/heads/%s", head_name);

builtin/gc.c

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

720720
if (cfg.pack_refs < 0)
721-
cfg.pack_refs = !is_bare_repository();
721+
cfg.pack_refs = !repo_is_bare(the_repository);
722722

723723
argc = parse_options(argc, argv, prefix, builtin_gc_options,
724724
builtin_gc_usage, 0);

builtin/init-db.c

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

110110
argc = parse_options(argc, argv, prefix, init_db_options, init_db_usage, 0);
111111

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

115115
if (real_git_dir && !is_absolute_path(real_git_dir))
@@ -155,7 +155,7 @@ int cmd_init_db(int argc,
155155
} else if (0 < argc) {
156156
usage(init_db_usage[0]);
157157
}
158-
if (is_bare_repository_cfg == 1) {
158+
if (the_repository->is_bare_cfg == 1) {
159159
char *cwd = xgetcwd();
160160
setenv(GIT_DIR_ENVIRONMENT, cwd, argc > 0);
161161
free(cwd);
@@ -182,7 +182,7 @@ int cmd_init_db(int argc,
182182
*/
183183
git_dir = xstrdup_or_null(getenv(GIT_DIR_ENVIRONMENT));
184184
work_tree = xstrdup_or_null(getenv(GIT_WORK_TREE_ENVIRONMENT));
185-
if ((!git_dir || is_bare_repository_cfg == 1) && work_tree)
185+
if ((!git_dir || the_repository->is_bare_cfg == 1) && work_tree)
186186
die(_("%s (or --work-tree=<directory>) not allowed without "
187187
"specifying %s (or --git-dir=<directory>)"),
188188
GIT_WORK_TREE_ENVIRONMENT,
@@ -218,10 +218,10 @@ int cmd_init_db(int argc,
218218
strbuf_release(&sb);
219219
}
220220

221-
if (is_bare_repository_cfg < 0)
222-
is_bare_repository_cfg = guess_repository_type(git_dir);
221+
if (the_repository->is_bare_cfg < 0)
222+
the_repository->is_bare_cfg = guess_repository_type(git_dir);
223223

224-
if (!is_bare_repository_cfg) {
224+
if (!the_repository->is_bare_cfg) {
225225
const char *git_dir_parent = strrchr(git_dir, '/');
226226
if (git_dir_parent) {
227227
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)