|
31 | 31 | #include "packfile.h" |
32 | 32 | #include "object-store.h" |
33 | 33 |
|
| 34 | +#define IN_PACK(obj) oe_in_pack(&to_pack, obj) |
| 35 | + |
34 | 36 | static const char *pack_usage[] = { |
35 | 37 | N_("git pack-objects --stdout [<options>...] [< <ref-list> | < <object-list>]"), |
36 | 38 | N_("git pack-objects [<options>...] <base-name> [< <ref-list> | < <object-list>]"), |
@@ -367,7 +369,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent |
367 | 369 | static off_t write_reuse_object(struct hashfile *f, struct object_entry *entry, |
368 | 370 | unsigned long limit, int usable_delta) |
369 | 371 | { |
370 | | - struct packed_git *p = entry->in_pack; |
| 372 | + struct packed_git *p = IN_PACK(entry); |
371 | 373 | struct pack_window *w_curs = NULL; |
372 | 374 | struct revindex_entry *revidx; |
373 | 375 | off_t offset; |
@@ -478,7 +480,7 @@ static off_t write_object(struct hashfile *f, |
478 | 480 |
|
479 | 481 | if (!reuse_object) |
480 | 482 | to_reuse = 0; /* explicit */ |
481 | | - else if (!entry->in_pack) |
| 483 | + else if (!IN_PACK(entry)) |
482 | 484 | to_reuse = 0; /* can't reuse what we don't have */ |
483 | 485 | else if (oe_type(entry) == OBJ_REF_DELTA || |
484 | 486 | oe_type(entry) == OBJ_OFS_DELTA) |
@@ -1074,7 +1076,7 @@ static void create_object_entry(const struct object_id *oid, |
1074 | 1076 | else |
1075 | 1077 | nr_result++; |
1076 | 1078 | if (found_pack) { |
1077 | | - entry->in_pack = found_pack; |
| 1079 | + oe_set_in_pack(&to_pack, entry, found_pack); |
1078 | 1080 | entry->in_pack_offset = found_offset; |
1079 | 1081 | } |
1080 | 1082 |
|
@@ -1399,8 +1401,8 @@ static void cleanup_preferred_base(void) |
1399 | 1401 |
|
1400 | 1402 | static void check_object(struct object_entry *entry) |
1401 | 1403 | { |
1402 | | - if (entry->in_pack) { |
1403 | | - struct packed_git *p = entry->in_pack; |
| 1404 | + if (IN_PACK(entry)) { |
| 1405 | + struct packed_git *p = IN_PACK(entry); |
1404 | 1406 | struct pack_window *w_curs = NULL; |
1405 | 1407 | const unsigned char *base_ref = NULL; |
1406 | 1408 | struct object_entry *base_entry; |
@@ -1535,14 +1537,16 @@ static int pack_offset_sort(const void *_a, const void *_b) |
1535 | 1537 | { |
1536 | 1538 | const struct object_entry *a = *(struct object_entry **)_a; |
1537 | 1539 | const struct object_entry *b = *(struct object_entry **)_b; |
| 1540 | + const struct packed_git *a_in_pack = IN_PACK(a); |
| 1541 | + const struct packed_git *b_in_pack = IN_PACK(b); |
1538 | 1542 |
|
1539 | 1543 | /* avoid filesystem trashing with loose objects */ |
1540 | | - if (!a->in_pack && !b->in_pack) |
| 1544 | + if (!a_in_pack && !b_in_pack) |
1541 | 1545 | return oidcmp(&a->idx.oid, &b->idx.oid); |
1542 | 1546 |
|
1543 | | - if (a->in_pack < b->in_pack) |
| 1547 | + if (a_in_pack < b_in_pack) |
1544 | 1548 | return -1; |
1545 | | - if (a->in_pack > b->in_pack) |
| 1549 | + if (a_in_pack > b_in_pack) |
1546 | 1550 | return 1; |
1547 | 1551 | return a->in_pack_offset < b->in_pack_offset ? -1 : |
1548 | 1552 | (a->in_pack_offset > b->in_pack_offset); |
@@ -1578,7 +1582,7 @@ static void drop_reused_delta(struct object_entry *entry) |
1578 | 1582 |
|
1579 | 1583 | oi.sizep = &entry->size; |
1580 | 1584 | oi.typep = &type; |
1581 | | - if (packed_object_info(entry->in_pack, entry->in_pack_offset, &oi) < 0) { |
| 1585 | + if (packed_object_info(IN_PACK(entry), entry->in_pack_offset, &oi) < 0) { |
1582 | 1586 | /* |
1583 | 1587 | * We failed to get the info from this pack for some reason; |
1584 | 1588 | * fall back to sha1_object_info, which may find another copy. |
@@ -1848,8 +1852,8 @@ static int try_delta(struct unpacked *trg, struct unpacked *src, |
1848 | 1852 | * it, we will still save the transfer cost, as we already know |
1849 | 1853 | * the other side has it and we won't send src_entry at all. |
1850 | 1854 | */ |
1851 | | - if (reuse_delta && trg_entry->in_pack && |
1852 | | - trg_entry->in_pack == src_entry->in_pack && |
| 1855 | + if (reuse_delta && IN_PACK(trg_entry) && |
| 1856 | + IN_PACK(trg_entry) == IN_PACK(src_entry) && |
1853 | 1857 | !src_entry->preferred_base && |
1854 | 1858 | trg_entry->in_pack_type != OBJ_REF_DELTA && |
1855 | 1859 | trg_entry->in_pack_type != OBJ_OFS_DELTA) |
@@ -3192,6 +3196,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) |
3192 | 3196 | } |
3193 | 3197 | } |
3194 | 3198 |
|
| 3199 | + prepare_packing_data(&to_pack); |
| 3200 | + |
3195 | 3201 | if (progress) |
3196 | 3202 | progress_state = start_progress(_("Counting objects"), 0); |
3197 | 3203 | if (!use_internal_rev_list) |
|
0 commit comments