| 4298 | } |
| 4299 | |
| 4300 | static void read_cruft_objects(void) |
| 4301 | { |
| 4302 | struct strbuf buf = STRBUF_INIT; |
| 4303 | struct string_list discard_packs = STRING_LIST_INIT_DUP; |
| 4304 | struct string_list fresh_packs = STRING_LIST_INIT_DUP; |
| 4305 | struct packed_git *p; |
| 4306 | |
| 4307 | ignore_packed_keep_in_core = 1; |
| 4308 | |
| 4309 | while (strbuf_getline(&buf, stdin) != EOF) { |
| 4310 | if (!buf.len) |
| 4311 | continue; |
| 4312 | |
| 4313 | if (*buf.buf == '-') |
| 4314 | string_list_append(&discard_packs, buf.buf + 1); |
| 4315 | else |
| 4316 | string_list_append(&fresh_packs, buf.buf); |
| 4317 | } |
| 4318 | |
| 4319 | string_list_sort(&discard_packs); |
| 4320 | string_list_sort(&fresh_packs); |
| 4321 | |
| 4322 | repo_for_each_pack(the_repository, p) { |
| 4323 | const char *pack_name = pack_basename(p); |
| 4324 | struct string_list_item *item; |
| 4325 | |
| 4326 | item = string_list_lookup(&fresh_packs, pack_name); |
| 4327 | if (!item) |
| 4328 | item = string_list_lookup(&discard_packs, pack_name); |
| 4329 | |
| 4330 | if (item) { |
| 4331 | item->util = p; |
| 4332 | } else { |
| 4333 | /* |
| 4334 | * This pack wasn't mentioned in either the "fresh" or |
| 4335 | * "discard" list, so the caller didn't know about it. |
| 4336 | * |
| 4337 | * Mark it as kept so that its objects are ignored by |
| 4338 | * add_unseen_recent_objects_to_traversal(). We'll |
| 4339 | * unmark it before starting the traversal so it doesn't |
| 4340 | * halt the traversal early. |
| 4341 | */ |
| 4342 | p->pack_keep_in_core = 1; |
| 4343 | } |
| 4344 | } |
| 4345 | |
| 4346 | mark_pack_kept_in_core(&fresh_packs, 1); |
| 4347 | mark_pack_kept_in_core(&discard_packs, 0); |
| 4348 | |
| 4349 | if (cruft_expiration) |
| 4350 | enumerate_and_traverse_cruft_objects(&fresh_packs); |
| 4351 | else |
| 4352 | enumerate_cruft_objects(); |
| 4353 | |
| 4354 | strbuf_release(&buf); |
| 4355 | string_list_clear(&discard_packs, 0); |
| 4356 | string_list_clear(&fresh_packs, 0); |
| 4357 | } |
no test coverage detected