Skip to content

Commit e943a41

Browse files
committed
fixup! pack-objects: extract should_attempt_deltas()
1 parent 8c6b995 commit e943a41

File tree

1 file changed

+24
-29
lines changed

1 file changed

+24
-29
lines changed

builtin/pack-objects.c

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3283,33 +3283,6 @@ static int add_ref_tag(const char *tag UNUSED, const char *referent UNUSED, cons
32833283
return 0;
32843284
}
32853285

3286-
static int should_attempt_deltas(struct object_entry *entry)
3287-
{
3288-
if (DELTA(entry))
3289-
return 0;
3290-
3291-
if (!entry->type_valid ||
3292-
oe_size_less_than(&to_pack, entry, 50))
3293-
return 0;
3294-
3295-
if (entry->no_try_delta)
3296-
return 0;
3297-
3298-
if (!entry->preferred_base) {
3299-
if (oe_type(entry) < 0)
3300-
die(_("unable to get type of object %s"),
3301-
oid_to_hex(&entry->idx.oid));
3302-
} else if (oe_type(entry) < 0) {
3303-
/*
3304-
* This object is not found, but we
3305-
* don't have to include it anyway.
3306-
*/
3307-
return 0;
3308-
}
3309-
3310-
return 1;
3311-
}
3312-
33133286
static void prepare_pack(int window, int depth)
33143287
{
33153288
struct object_entry **delta_list;
@@ -3340,11 +3313,33 @@ static void prepare_pack(int window, int depth)
33403313
for (i = 0; i < to_pack.nr_objects; i++) {
33413314
struct object_entry *entry = to_pack.objects + i;
33423315

3343-
if (!should_attempt_deltas(entry))
3316+
if (DELTA(entry))
3317+
/* This happens if we decided to reuse existing
3318+
* delta from a pack. "reuse_delta &&" is implied.
3319+
*/
33443320
continue;
33453321

3346-
if (!entry->preferred_base)
3322+
if (!entry->type_valid ||
3323+
oe_size_less_than(&to_pack, entry, 50))
3324+
continue;
3325+
3326+
if (entry->no_try_delta)
3327+
continue;
3328+
3329+
if (!entry->preferred_base) {
33473330
nr_deltas++;
3331+
if (oe_type(entry) < 0)
3332+
die(_("unable to get type of object %s"),
3333+
oid_to_hex(&entry->idx.oid));
3334+
} else {
3335+
if (oe_type(entry) < 0) {
3336+
/*
3337+
* This object is not found, but we
3338+
* don't have to include it anyway.
3339+
*/
3340+
continue;
3341+
}
3342+
}
33483343

33493344
delta_list[n++] = entry;
33503345
}

0 commit comments

Comments
 (0)