Skip to content

Commit b31f2aa

Browse files
ttaylorrgitster
authored andcommitted
midx: teach midx_preferred_pack() about incremental MIDXs
The function `midx_preferred_pack()` is used to determine the identity of the preferred pack, which is the identity of a unique pack within the MIDX which is used as a tie-breaker when selecting from which pack to represent an object that appears in multiple packs within the MIDX. Historically we have said that the MIDX's preferred pack has the unique property that all objects from that pack are represented in the MIDX. But that isn't quite true: a more precise statement would be that all objects from that pack *which appear in the MIDX* are selected from that pack. This helps us extend the concept of preferred packs across a MIDX chain, where some object(s) in the preferred pack may appear in other packs in an earlier MIDX layer, in which case those object(s) will not appear in a subsequent MIDX layer from either the preferred pack or any other pack. Extend the concept of preferred packs by using the pack which represents the object at the first position in MIDX pseudo-pack order belonging to the current MIDX layer (i.e., at position 'm->num_objects_in_base'). Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 853165c commit b31f2aa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

midx.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,13 +501,16 @@ int midx_contains_pack(struct multi_pack_index *m, const char *idx_or_pack_name)
501501
int midx_preferred_pack(struct multi_pack_index *m, uint32_t *pack_int_id)
502502
{
503503
if (m->preferred_pack_idx == -1) {
504+
uint32_t midx_pos;
504505
if (load_midx_revindex(m) < 0) {
505506
m->preferred_pack_idx = -2;
506507
return -1;
507508
}
508509

509-
m->preferred_pack_idx =
510-
nth_midxed_pack_int_id(m, pack_pos_to_midx(m, 0));
510+
midx_pos = pack_pos_to_midx(m, m->num_objects_in_base);
511+
512+
m->preferred_pack_idx = nth_midxed_pack_int_id(m, midx_pos);
513+
511514
} else if (m->preferred_pack_idx == -2)
512515
return -1; /* no revindex */
513516

0 commit comments

Comments
 (0)