| 2086 | } |
| 2087 | |
| 2088 | int midx_repack(struct odb_source *source, size_t batch_size, unsigned flags) |
| 2089 | { |
| 2090 | struct repository *r = source->odb->repo; |
| 2091 | int result = 0; |
| 2092 | uint32_t i, packs_to_repack = 0; |
| 2093 | unsigned char *include_pack; |
| 2094 | struct child_process cmd = CHILD_PROCESS_INIT; |
| 2095 | FILE *cmd_in; |
| 2096 | struct multi_pack_index *m = get_multi_pack_index(source); |
| 2097 | struct write_midx_opts opts = { |
| 2098 | .source = source, |
| 2099 | .flags = flags, |
| 2100 | }; |
| 2101 | |
| 2102 | /* |
| 2103 | * When updating the default for these configuration |
| 2104 | * variables in builtin/repack.c, these must be adjusted |
| 2105 | * to match. |
| 2106 | */ |
| 2107 | int delta_base_offset = 1; |
| 2108 | int use_delta_islands = 0; |
| 2109 | |
| 2110 | if (!m) |
| 2111 | return 0; |
| 2112 | if (m->base_midx) |
| 2113 | die(_("cannot repack an incremental multi-pack-index")); |
| 2114 | |
| 2115 | CALLOC_ARRAY(include_pack, m->num_packs); |
| 2116 | |
| 2117 | if (batch_size) |
| 2118 | fill_included_packs_batch(r, m, include_pack, batch_size); |
| 2119 | else |
| 2120 | fill_included_packs_all(r, m, include_pack); |
| 2121 | |
| 2122 | for (i = 0; i < m->num_packs; i++) { |
| 2123 | if (include_pack[i]) |
| 2124 | packs_to_repack++; |
| 2125 | } |
| 2126 | if (packs_to_repack <= 1) |
| 2127 | goto cleanup; |
| 2128 | |
| 2129 | repo_config_get_bool(r, "repack.usedeltabaseoffset", &delta_base_offset); |
| 2130 | repo_config_get_bool(r, "repack.usedeltaislands", &use_delta_islands); |
| 2131 | |
| 2132 | strvec_push(&cmd.args, "pack-objects"); |
| 2133 | |
| 2134 | strvec_pushf(&cmd.args, "%s/pack/pack", source->path); |
| 2135 | |
| 2136 | if (delta_base_offset) |
| 2137 | strvec_push(&cmd.args, "--delta-base-offset"); |
| 2138 | if (use_delta_islands) |
| 2139 | strvec_push(&cmd.args, "--delta-islands"); |
| 2140 | |
| 2141 | if (flags & MIDX_PROGRESS) |
| 2142 | strvec_push(&cmd.args, "--progress"); |
| 2143 | else |
| 2144 | strvec_push(&cmd.args, "-q"); |
| 2145 |
no test coverage detected