@@ -3161,6 +3161,33 @@ static int add_ref_tag(const char *tag UNUSED, const char *referent UNUSED, cons
31613161 return 0 ;
31623162}
31633163
3164+ static int should_attempt_deltas (struct object_entry * entry )
3165+ {
3166+ if (DELTA (entry ))
3167+ return 0 ;
3168+
3169+ if (!entry -> type_valid ||
3170+ oe_size_less_than (& to_pack , entry , 50 ))
3171+ return 0 ;
3172+
3173+ if (entry -> no_try_delta )
3174+ return 0 ;
3175+
3176+ if (!entry -> preferred_base ) {
3177+ if (oe_type (entry ) < 0 )
3178+ die (_ ("unable to get type of object %s" ),
3179+ oid_to_hex (& entry -> idx .oid ));
3180+ } else if (oe_type (entry ) < 0 ) {
3181+ /*
3182+ * This object is not found, but we
3183+ * don't have to include it anyway.
3184+ */
3185+ return 0 ;
3186+ }
3187+
3188+ return 1 ;
3189+ }
3190+
31643191static void prepare_pack (int window , int depth )
31653192{
31663193 struct object_entry * * delta_list ;
@@ -3191,33 +3218,11 @@ static void prepare_pack(int window, int depth)
31913218 for (i = 0 ; i < to_pack .nr_objects ; i ++ ) {
31923219 struct object_entry * entry = to_pack .objects + i ;
31933220
3194- if (DELTA (entry ))
3195- /* This happens if we decided to reuse existing
3196- * delta from a pack. "reuse_delta &&" is implied.
3197- */
3198- continue ;
3199-
3200- if (!entry -> type_valid ||
3201- oe_size_less_than (& to_pack , entry , 50 ))
3221+ if (!should_attempt_deltas (entry ))
32023222 continue ;
32033223
3204- if (entry -> no_try_delta )
3205- continue ;
3206-
3207- if (!entry -> preferred_base ) {
3224+ if (!entry -> preferred_base )
32083225 nr_deltas ++ ;
3209- if (oe_type (entry ) < 0 )
3210- die (_ ("unable to get type of object %s" ),
3211- oid_to_hex (& entry -> idx .oid ));
3212- } else {
3213- if (oe_type (entry ) < 0 ) {
3214- /*
3215- * This object is not found, but we
3216- * don't have to include it anyway.
3217- */
3218- continue ;
3219- }
3220- }
32213226
32223227 delta_list [n ++ ] = entry ;
32233228 }
0 commit comments