MCPcopy Create free account
hub / github.com/git/git / prepare_pack

Function prepare_pack

builtin/pack-objects.c:3612–3669  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3610}
3611
3612static void prepare_pack(int window, int depth)
3613{
3614 struct object_entry **delta_list;
3615 uint32_t i, nr_deltas;
3616 unsigned n;
3617
3618 if (use_delta_islands)
3619 resolve_tree_islands(the_repository, progress, &to_pack);
3620
3621 get_object_details();
3622
3623 /*
3624 * If we're locally repacking then we need to be doubly careful
3625 * from now on in order to make sure no stealth corruption gets
3626 * propagated to the new pack. Clients receiving streamed packs
3627 * should validate everything they get anyway so no need to incur
3628 * the additional cost here in that case.
3629 */
3630 if (!pack_to_stdout)
3631 do_check_packed_object_crc = 1;
3632
3633 if (!to_pack.nr_objects || !window || !depth)
3634 return;
3635
3636 if (path_walk)
3637 ll_find_deltas_by_region(to_pack.objects, to_pack.regions,
3638 0, to_pack.nr_regions);
3639
3640 ALLOC_ARRAY(delta_list, to_pack.nr_objects);
3641 nr_deltas = n = 0;
3642
3643 for (i = 0; i < to_pack.nr_objects; i++) {
3644 struct object_entry *entry = to_pack.objects + i;
3645
3646 if (!should_attempt_deltas(entry))
3647 continue;
3648
3649 if (!entry->preferred_base)
3650 nr_deltas++;
3651
3652 delta_list[n++] = entry;
3653 }
3654
3655 if (nr_deltas && n > 1) {
3656 unsigned nr_done = 0;
3657
3658 if (progress)
3659 progress_state = start_progress(the_repository,
3660 _("Compressing objects"),
3661 nr_deltas);
3662 QSORT(delta_list, n, type_size_sort);
3663 ll_find_deltas(delta_list, n, window+1, depth, &nr_done);
3664 stop_progress(&progress_state);
3665 if (nr_done != nr_deltas)
3666 die(_("inconsistency with delta count"));
3667 }
3668 free(delta_list);
3669}

Callers 1

cmd_pack_objectsFunction · 0.70

Calls 8

resolve_tree_islandsFunction · 0.85
get_object_detailsFunction · 0.85
ll_find_deltas_by_regionFunction · 0.85
should_attempt_deltasFunction · 0.85
start_progressFunction · 0.85
ll_find_deltasFunction · 0.85
stop_progressFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected