|
1 | | -#define USE_THE_REPOSITORY_VARIABLE |
2 | | - |
3 | 1 | #include "git-compat-util.h" |
4 | 2 | #include "gettext.h" |
5 | 3 | #include "object-file.h" |
|
8 | 6 | #include "prune-packed.h" |
9 | 7 | #include "repository.h" |
10 | 8 |
|
| 9 | +struct prune_data { |
| 10 | + struct repository *r; |
| 11 | + int opts; |
| 12 | +}; |
| 13 | + |
11 | 14 | static struct progress *progress; |
12 | 15 |
|
13 | 16 | static int prune_subdir(unsigned int nr, const char *path, void *data) |
14 | 17 | { |
15 | | - int *opts = data; |
| 18 | + struct prune_data *d = data; |
16 | 19 | display_progress(progress, nr + 1); |
17 | | - if (!(*opts & PRUNE_PACKED_DRY_RUN)) |
| 20 | + if (!(d->opts & PRUNE_PACKED_DRY_RUN)) |
18 | 21 | rmdir(path); |
19 | 22 | return 0; |
20 | 23 | } |
21 | 24 |
|
22 | 25 | static int prune_object(const struct object_id *oid, const char *path, |
23 | | - void *data) |
| 26 | + void *data) |
24 | 27 | { |
25 | | - int *opts = data; |
| 28 | + struct prune_data *d = data; |
26 | 29 |
|
27 | | - if (!has_object_pack(the_repository, oid)) |
| 30 | + if (!repo_has_object_pack(d->r, oid)) |
28 | 31 | return 0; |
29 | 32 |
|
30 | | - if (*opts & PRUNE_PACKED_DRY_RUN) |
| 33 | + if (d->opts & PRUNE_PACKED_DRY_RUN) |
31 | 34 | printf("rm -f %s\n", path); |
32 | 35 | else |
33 | 36 | unlink_or_warn(path); |
34 | 37 | return 0; |
35 | 38 | } |
36 | 39 |
|
37 | | -void prune_packed_objects(int opts) |
| 40 | +void prune_packed_objects(struct repository *r, int opts) |
38 | 41 | { |
| 42 | + struct prune_data cb_data = { |
| 43 | + .r = r, |
| 44 | + .opts = opts |
| 45 | + }; |
| 46 | + |
39 | 47 | if (opts & PRUNE_PACKED_VERBOSE) |
40 | | - progress = start_delayed_progress(the_repository, |
| 48 | + progress = start_delayed_progress(r, |
41 | 49 | _("Removing duplicate objects"), 256); |
42 | 50 |
|
43 | | - for_each_loose_file_in_source(the_repository->objects->sources, |
44 | | - prune_object, NULL, prune_subdir, &opts); |
| 51 | + for_each_loose_file_in_source(r->objects->sources, |
| 52 | + prune_object, NULL, prune_subdir, &cb_data); |
45 | 53 |
|
46 | 54 | /* Ensure we show 100% before finishing progress */ |
47 | 55 | display_progress(progress, 256); |
|
0 commit comments