repository: move 'repository_format_precious_objects' to repo scope
The 'extensions.preciousObjects' setting when set true, prevents operations that might drop objects from the object storage. This setting is populated in the global variable 'repository_format_precious_objects'. Move this global variable to repo scope by adding it to 'struct repository and also refactor all the occurences accordingly. This change is part of an ongoing effort to eliminate global variables, improve modularity and help libify the codebase. Mentored-by: Christian Couder <christian.couder@gmail.com> Mentored-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com> Signed-off-by: Ayush Chandekar <ayu.chandekar@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
cf6f63ea6b
commit
44e300a974
|
@ -998,7 +998,7 @@ int cmd_gc(int argc,
|
|||
if (opts.detach <= 0 && !skip_foreground_tasks)
|
||||
gc_foreground_tasks(&opts, &cfg);
|
||||
|
||||
if (!repository_format_precious_objects) {
|
||||
if (!the_repository->repository_format_precious_objects) {
|
||||
struct child_process repack_cmd = CHILD_PROCESS_INIT;
|
||||
|
||||
repack_cmd.git_cmd = 1;
|
||||
|
|
|
@ -177,7 +177,7 @@ int cmd_prune(int argc,
|
|||
|
||||
argc = parse_options(argc, argv, prefix, options, prune_usage, 0);
|
||||
|
||||
if (repository_format_precious_objects)
|
||||
if (the_repository->repository_format_precious_objects)
|
||||
die(_("cannot prune in a precious-objects repo"));
|
||||
|
||||
while (argc--) {
|
||||
|
|
|
@ -1240,7 +1240,7 @@ int cmd_repack(int argc,
|
|||
po_args.depth = xstrdup_or_null(opt_depth);
|
||||
po_args.threads = xstrdup_or_null(opt_threads);
|
||||
|
||||
if (delete_redundant && repository_format_precious_objects)
|
||||
if (delete_redundant && the_repository->repository_format_precious_objects)
|
||||
die(_("cannot delete packs in a precious-objects repo"));
|
||||
|
||||
die_for_incompatible_opt3(unpack_unreachable || (pack_everything & LOOSEN_UNREACHABLE), "-A",
|
||||
|
|
|
@ -37,7 +37,6 @@ int ignore_case;
|
|||
int assume_unchanged;
|
||||
int is_bare_repository_cfg = -1; /* unspecified */
|
||||
int warn_on_object_refname_ambiguity = 1;
|
||||
int repository_format_precious_objects;
|
||||
char *git_commit_encoding;
|
||||
char *git_log_output_encoding;
|
||||
char *apply_default_whitespace;
|
||||
|
|
|
@ -189,8 +189,6 @@ extern enum object_creation_mode object_creation_mode;
|
|||
|
||||
extern int grafts_keep_true_parents;
|
||||
|
||||
extern int repository_format_precious_objects;
|
||||
|
||||
const char *get_log_output_encoding(void);
|
||||
const char *get_commit_output_encoding(void);
|
||||
|
||||
|
|
|
@ -284,6 +284,7 @@ int repo_init(struct repository *repo,
|
|||
repo_set_ref_storage_format(repo, format.ref_storage_format);
|
||||
repo->repository_format_worktree_config = format.worktree_config;
|
||||
repo->repository_format_relative_worktrees = format.relative_worktrees;
|
||||
repo->repository_format_precious_objects = format.precious_objects;
|
||||
|
||||
/* take ownership of format.partial_clone */
|
||||
repo->repository_format_partial_clone = format.partial_clone;
|
||||
|
|
|
@ -151,6 +151,7 @@ struct repository {
|
|||
/* Configurations */
|
||||
int repository_format_worktree_config;
|
||||
int repository_format_relative_worktrees;
|
||||
int repository_format_precious_objects;
|
||||
|
||||
/* Indicate if a repository has a different 'commondir' from 'gitdir' */
|
||||
unsigned different_commondir:1;
|
||||
|
|
5
setup.c
5
setup.c
|
@ -753,7 +753,8 @@ static int check_repository_format_gently(const char *gitdir, struct repository_
|
|||
die("%s", err.buf);
|
||||
}
|
||||
|
||||
repository_format_precious_objects = candidate->precious_objects;
|
||||
the_repository->repository_format_precious_objects = candidate->precious_objects;
|
||||
|
||||
string_list_clear(&candidate->unknown_extensions, 0);
|
||||
string_list_clear(&candidate->v1_only_extensions, 0);
|
||||
|
||||
|
@ -1864,6 +1865,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
|
|||
the_repository->repository_format_partial_clone =
|
||||
repo_fmt.partial_clone;
|
||||
repo_fmt.partial_clone = NULL;
|
||||
the_repository->repository_format_precious_objects =
|
||||
repo_fmt.precious_objects;
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue