Re: [PATCH 1/3] make index-pâck able to complete thin packs
- From
Junio C Hamano <junkio@cox.net>
- Date
- Oct 27, 2006, 22:28 UTC
- Message-ID
- <7vmz7hcs0o.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <Pine.LNX.4.64.0610252323100.12418@xanadu.home>
Nicolas Pitre <nico@cam.org> writes:
Show 37 quoted lines
> +static void fix_unresolved_deltas(int nr_unresolved)
> +{
> + struct delta_entry **sorted_by_pos;
> + int i, n = 0;
> +
> + /*
> + * Since many unresolved deltas may well be themselves base objects
> + * for more unresolved deltas, we really want to include the
> + * smallest number of base objects that would cover as much delta
> + * as possible by picking the
> + * trunc deltas first, allowing for other deltas to resolve without
> + * additional base objects. Since most base objects are to be found
> + * before deltas depending on them, a good heuristic is to start
> + * resolving deltas in the same order as their position in the pack.
> + */
> + sorted_by_pos = xmalloc(nr_unresolved * sizeof(*sorted_by_pos));
> for (i = 0; i < nr_deltas; i++) {
> - if (deltas[i].obj->real_type == OBJ_REF_DELTA ||
> - deltas[i].obj->real_type == OBJ_OFS_DELTA)
> - die("pack has unresolved deltas");
> + if (objects[deltas[i].obj_no].real_type != OBJ_REF_DELTA)
> + continue;
> + sorted_by_pos[n++] = &deltas[i];
> }
>
> + qsort(sorted_by_pos, n, sizeof(*sorted_by_pos), delta_pos_compare);
> +
> + for (i = 0; i < n; i++) {
> + struct delta_entry *d = sorted_by_pos[i];
> + void *data;
> + unsigned long size;
> + char type[10];
> + enum object_type obj_type;
> + int j, first, last;
> +
> + if (objects[d->obj_no].real_type != OBJ_REF_DELTA)
> + continue;Just for the sake of my own sanity checking,...
Is it because base objects of OFS_DELTA _must_ exist in the same pack (even when --thin) that we do not have to worry about them in this function?