Skip to content

Commit a842a77

Browse files
committed
Merge branch 'ac/prune-wo-the-repository' into seen
* ac/prune-wo-the-repository: builtin/prune: stop depending on 'the_repository' repository: move 'repository_format_precious_objects' to repo scope
2 parents ef6fa38 + f25fc39 commit a842a77

8 files changed

Lines changed: 21 additions & 21 deletions

File tree

builtin/gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ int cmd_gc(int argc,
998998
if (opts.detach <= 0 && !skip_foreground_tasks)
999999
gc_foreground_tasks(&opts, &cfg);
10001000

1001-
if (!repository_format_precious_objects) {
1001+
if (!the_repository->repository_format_precious_objects) {
10021002
struct child_process repack_cmd = CHILD_PROCESS_INIT;
10031003

10041004
repack_cmd.git_cmd = 1;

builtin/prune.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#define USE_THE_REPOSITORY_VARIABLE
21
#define DISABLE_SIGN_COMPARE_WARNINGS
32

43
#include "builtin.h"
@@ -64,7 +63,7 @@ static void perform_reachability_traversal(struct rev_info *revs)
6463
return;
6564

6665
if (show_progress)
67-
progress = start_delayed_progress(the_repository,
66+
progress = start_delayed_progress(revs->repo,
6867
_("Checking connectivity"), 0);
6968
mark_reachable_objects(revs, 1, expire, progress);
7069
stop_progress(&progress);
@@ -78,7 +77,7 @@ static int is_object_reachable(const struct object_id *oid,
7877

7978
perform_reachability_traversal(revs);
8079

81-
obj = lookup_object(the_repository, oid);
80+
obj = lookup_object(revs->repo, oid);
8281
return obj && (obj->flags & SEEN);
8382
}
8483

@@ -99,8 +98,8 @@ static int prune_object(const struct object_id *oid, const char *fullpath,
9998
if (st.st_mtime > expire)
10099
return 0;
101100
if (show_only || verbose) {
102-
enum object_type type = odb_read_object_info(the_repository->objects,
103-
oid, NULL);
101+
enum object_type type =
102+
odb_read_object_info(revs->repo->objects, oid, NULL);
104103
printf("%s %s\n", oid_to_hex(oid),
105104
(type > 0) ? type_name(type) : "unknown");
106105
}
@@ -154,7 +153,7 @@ static void remove_temporary_files(const char *path)
154153
int cmd_prune(int argc,
155154
const char **argv,
156155
const char *prefix,
157-
struct repository *repo UNUSED)
156+
struct repository *repo)
158157
{
159158
struct rev_info revs;
160159
int exclude_promisor_objects = 0;
@@ -173,20 +172,19 @@ int cmd_prune(int argc,
173172
expire = TIME_MAX;
174173
save_commit_buffer = 0;
175174
disable_replace_refs();
176-
repo_init_revisions(the_repository, &revs, prefix);
175+
repo_init_revisions(repo, &revs, prefix);
177176

178177
argc = parse_options(argc, argv, prefix, options, prune_usage, 0);
179178

180-
if (repository_format_precious_objects)
179+
if (repo->repository_format_precious_objects)
181180
die(_("cannot prune in a precious-objects repo"));
182181

183182
while (argc--) {
184183
struct object_id oid;
185184
const char *name = *argv++;
186185

187-
if (!repo_get_oid(the_repository, name, &oid)) {
188-
struct object *object = parse_object_or_die(the_repository, &oid,
189-
name);
186+
if (!repo_get_oid(repo, name, &oid)) {
187+
struct object *object = parse_object_or_die(repo, &oid, name);
190188
add_pending_object(&revs, object, "");
191189
}
192190
else
@@ -200,16 +198,16 @@ int cmd_prune(int argc,
200198
revs.exclude_promisor_objects = 1;
201199
}
202200

203-
for_each_loose_file_in_objdir(repo_get_object_directory(the_repository),
201+
for_each_loose_file_in_objdir(repo_get_object_directory(repo),
204202
prune_object, prune_cruft, prune_subdir, &revs);
205203

206204
prune_packed_objects(show_only ? PRUNE_PACKED_DRY_RUN : 0);
207-
remove_temporary_files(repo_get_object_directory(the_repository));
208-
s = mkpathdup("%s/pack", repo_get_object_directory(the_repository));
205+
remove_temporary_files(repo_get_object_directory(repo));
206+
s = mkpathdup("%s/pack", repo_get_object_directory(repo));
209207
remove_temporary_files(s);
210208
free(s);
211209

212-
if (is_repository_shallow(the_repository)) {
210+
if (is_repository_shallow(repo)) {
213211
perform_reachability_traversal(&revs);
214212
prune_shallow(show_only ? PRUNE_SHOW_ONLY : 0);
215213
}

builtin/repack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ int cmd_repack(int argc,
13501350
po_args.depth = xstrdup_or_null(opt_depth);
13511351
po_args.threads = xstrdup_or_null(opt_threads);
13521352

1353-
if (delete_redundant && repository_format_precious_objects)
1353+
if (delete_redundant && the_repository->repository_format_precious_objects)
13541354
die(_("cannot delete packs in a precious-objects repo"));
13551355

13561356
die_for_incompatible_opt3(unpack_unreachable || (pack_everything & LOOSEN_UNREACHABLE), "-A",

environment.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ int ignore_case;
3737
int assume_unchanged;
3838
int is_bare_repository_cfg = -1; /* unspecified */
3939
int warn_on_object_refname_ambiguity = 1;
40-
int repository_format_precious_objects;
4140
char *git_commit_encoding;
4241
char *git_log_output_encoding;
4342
char *apply_default_whitespace;

environment.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@ extern enum object_creation_mode object_creation_mode;
185185

186186
extern int grafts_keep_true_parents;
187187

188-
extern int repository_format_precious_objects;
189-
190188
const char *get_log_output_encoding(void);
191189
const char *get_commit_output_encoding(void);
192190

repository.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ int repo_init(struct repository *repo,
285285
repo_set_ref_storage_format(repo, format.ref_storage_format);
286286
repo->repository_format_worktree_config = format.worktree_config;
287287
repo->repository_format_relative_worktrees = format.relative_worktrees;
288+
repo->repository_format_precious_objects = format.precious_objects;
288289

289290
/* take ownership of format.partial_clone */
290291
repo->repository_format_partial_clone = format.partial_clone;

repository.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ struct repository {
151151
/* Configurations */
152152
int repository_format_worktree_config;
153153
int repository_format_relative_worktrees;
154+
int repository_format_precious_objects;
154155

155156
/* Indicate if a repository has a different 'commondir' from 'gitdir' */
156157
unsigned different_commondir:1;

setup.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,8 @@ static int check_repository_format_gently(const char *gitdir, struct repository_
753753
die("%s", err.buf);
754754
}
755755

756-
repository_format_precious_objects = candidate->precious_objects;
756+
the_repository->repository_format_precious_objects = candidate->precious_objects;
757+
757758
string_list_clear(&candidate->unknown_extensions, 0);
758759
string_list_clear(&candidate->v1_only_extensions, 0);
759760

@@ -1867,6 +1868,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
18671868
the_repository->repository_format_partial_clone =
18681869
repo_fmt.partial_clone;
18691870
repo_fmt.partial_clone = NULL;
1871+
the_repository->repository_format_precious_objects =
1872+
repo_fmt.precious_objects;
18701873
}
18711874
}
18721875
/*

0 commit comments

Comments
 (0)