Git fork

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>

authored by

Ayush Chandekar and committed by
Junio C Hamano
44e300a9 cf6f63ea

+9 -7
+1 -1
builtin/gc.c
··· 998 998 if (opts.detach <= 0 && !skip_foreground_tasks) 999 999 gc_foreground_tasks(&opts, &cfg); 1000 1000 1001 - if (!repository_format_precious_objects) { 1001 + if (!the_repository->repository_format_precious_objects) { 1002 1002 struct child_process repack_cmd = CHILD_PROCESS_INIT; 1003 1003 1004 1004 repack_cmd.git_cmd = 1;
+1 -1
builtin/prune.c
··· 177 177 178 178 argc = parse_options(argc, argv, prefix, options, prune_usage, 0); 179 179 180 - if (repository_format_precious_objects) 180 + if (the_repository->repository_format_precious_objects) 181 181 die(_("cannot prune in a precious-objects repo")); 182 182 183 183 while (argc--) {
+1 -1
builtin/repack.c
··· 1240 1240 po_args.depth = xstrdup_or_null(opt_depth); 1241 1241 po_args.threads = xstrdup_or_null(opt_threads); 1242 1242 1243 - if (delete_redundant && repository_format_precious_objects) 1243 + if (delete_redundant && the_repository->repository_format_precious_objects) 1244 1244 die(_("cannot delete packs in a precious-objects repo")); 1245 1245 1246 1246 die_for_incompatible_opt3(unpack_unreachable || (pack_everything & LOOSEN_UNREACHABLE), "-A",
-1
environment.c
··· 37 37 int assume_unchanged; 38 38 int is_bare_repository_cfg = -1; /* unspecified */ 39 39 int warn_on_object_refname_ambiguity = 1; 40 - int repository_format_precious_objects; 41 40 char *git_commit_encoding; 42 41 char *git_log_output_encoding; 43 42 char *apply_default_whitespace;
-2
environment.h
··· 189 189 190 190 extern int grafts_keep_true_parents; 191 191 192 - extern int repository_format_precious_objects; 193 - 194 192 const char *get_log_output_encoding(void); 195 193 const char *get_commit_output_encoding(void); 196 194
+1
repository.c
··· 284 284 repo_set_ref_storage_format(repo, format.ref_storage_format); 285 285 repo->repository_format_worktree_config = format.worktree_config; 286 286 repo->repository_format_relative_worktrees = format.relative_worktrees; 287 + repo->repository_format_precious_objects = format.precious_objects; 287 288 288 289 /* take ownership of format.partial_clone */ 289 290 repo->repository_format_partial_clone = format.partial_clone;
+1
repository.h
··· 151 151 /* Configurations */ 152 152 int repository_format_worktree_config; 153 153 int repository_format_relative_worktrees; 154 + int repository_format_precious_objects; 154 155 155 156 /* Indicate if a repository has a different 'commondir' from 'gitdir' */ 156 157 unsigned different_commondir:1;
+4 -1
setup.c
··· 753 753 die("%s", err.buf); 754 754 } 755 755 756 - repository_format_precious_objects = candidate->precious_objects; 756 + the_repository->repository_format_precious_objects = candidate->precious_objects; 757 + 757 758 string_list_clear(&candidate->unknown_extensions, 0); 758 759 string_list_clear(&candidate->v1_only_extensions, 0); 759 760 ··· 1864 1865 the_repository->repository_format_partial_clone = 1865 1866 repo_fmt.partial_clone; 1866 1867 repo_fmt.partial_clone = NULL; 1868 + the_repository->repository_format_precious_objects = 1869 + repo_fmt.precious_objects; 1867 1870 } 1868 1871 } 1869 1872 /*