@@ -3196,6 +3196,36 @@ static int add_ref_tag(const char *tag UNUSED, const char *referent UNUSED, cons
31963196 return 0 ;
31973197}
31983198
3199+ static int should_attempt_deltas (struct object_entry * entry )
3200+ {
3201+ if (DELTA (entry ))
3202+ /* This happens if we decided to reuse existing
3203+ * delta from a pack. "reuse_delta &&" is implied.
3204+ */
3205+ return 0 ;
3206+
3207+ if (!entry -> type_valid ||
3208+ oe_size_less_than (& to_pack , entry , 50 ))
3209+ return 0 ;
3210+
3211+ if (entry -> no_try_delta )
3212+ return 0 ;
3213+
3214+ if (!entry -> preferred_base ) {
3215+ if (oe_type (entry ) < 0 )
3216+ die (_ ("unable to get type of object %s" ),
3217+ oid_to_hex (& entry -> idx .oid ));
3218+ } else if (oe_type (entry ) < 0 ) {
3219+ /*
3220+ * This object is not found, but we
3221+ * don't have to include it anyway.
3222+ */
3223+ return 0 ;
3224+ }
3225+
3226+ return 1 ;
3227+ }
3228+
31993229static void prepare_pack (int window , int depth )
32003230{
32013231 struct object_entry * * delta_list ;
@@ -3226,33 +3256,11 @@ static void prepare_pack(int window, int depth)
32263256 for (i = 0 ; i < to_pack .nr_objects ; i ++ ) {
32273257 struct object_entry * entry = to_pack .objects + i ;
32283258
3229- if (DELTA (entry ))
3230- /* This happens if we decided to reuse existing
3231- * delta from a pack. "reuse_delta &&" is implied.
3232- */
3233- continue ;
3234-
3235- if (!entry -> type_valid ||
3236- oe_size_less_than (& to_pack , entry , 50 ))
3259+ if (!should_attempt_deltas (entry ))
32373260 continue ;
32383261
3239- if (entry -> no_try_delta )
3240- continue ;
3241-
3242- if (!entry -> preferred_base ) {
3262+ if (!entry -> preferred_base )
32433263 nr_deltas ++ ;
3244- if (oe_type (entry ) < 0 )
3245- die (_ ("unable to get type of object %s" ),
3246- oid_to_hex (& entry -> idx .oid ));
3247- } else {
3248- if (oe_type (entry ) < 0 ) {
3249- /*
3250- * This object is not found, but we
3251- * don't have to include it anyway.
3252- */
3253- continue ;
3254- }
3255- }
32563264
32573265 delta_list [n ++ ] = entry ;
32583266 }
0 commit comments