@@ -191,7 +191,8 @@ static inline void oe_set_delta_size(struct packing_data *pack,
191191
192192static const char * const pack_usage [] = {
193193 N_ ("git pack-objects [-q | --progress | --all-progress] [--all-progress-implied]\n"
194- " [--no-reuse-delta] [--delta-base-offset] [--non-empty]\n"
194+ " [--no-reuse-delta] [--delta-base-offset] [--no-ref-delta]\n"
195+ " [--non-empty]\n"
195196 " [--local] [--incremental] [--window=<n>] [--depth=<n>]\n"
196197 " [--revs [--unpacked | --all]] [--keep-pack=<pack-name>]\n"
197198 " [--cruft] [--cruft-expiration=<time>]\n"
@@ -222,6 +223,7 @@ static int ignore_packed_keep_in_core;
222223static int ignore_packed_keep_in_core_open ;
223224static int ignore_packed_keep_in_core_has_cruft ;
224225static int allow_ofs_delta ;
226+ static int allow_ref_delta = 1 ;
225227static struct pack_idx_option pack_idx_opts ;
226228static const char * base_name ;
227229static int progress = 1 ;
@@ -2213,6 +2215,13 @@ static int can_reuse_delta(const struct object_id *base_oid,
22132215 */
22142216 base = packlist_find (& to_pack , base_oid );
22152217 if (base ) {
2218+ /*
2219+ * A preferred base is omitted from the resulting pack, so it
2220+ * can only be referenced by object ID.
2221+ */
2222+ if (base -> preferred_base && !allow_ref_delta )
2223+ return 0 ;
2224+
22162225 if (!in_same_island (& delta -> idx .oid , & base -> idx .oid ))
22172226 return 0 ;
22182227 * base_out = base ;
@@ -2224,7 +2233,8 @@ static int can_reuse_delta(const struct object_id *base_oid,
22242233 * even if it was buried too deep in history to make it into the
22252234 * packing list.
22262235 */
2227- if (thin && bitmap_has_oid_in_uninteresting (bitmap_git , base_oid )) {
2236+ if (allow_ref_delta && thin &&
2237+ bitmap_has_oid_in_uninteresting (bitmap_git , base_oid )) {
22282238 if (use_delta_islands ) {
22292239 if (!in_same_island (& delta -> idx .oid , base_oid ))
22302240 return 0 ;
@@ -3412,6 +3422,9 @@ static int should_attempt_deltas(struct object_entry *entry)
34123422 if (entry -> no_try_delta )
34133423 return 0 ;
34143424
3425+ if (entry -> preferred_base && !allow_ref_delta )
3426+ return 0 ;
3427+
34153428 if (!entry -> preferred_base ) {
34163429 if (oe_type (entry ) < 0 )
34173430 die (_ ("unable to get type of object %s" ),
@@ -3654,7 +3667,8 @@ static void prepare_pack(int window, int depth)
36543667 if (!pack_to_stdout )
36553668 do_check_packed_object_crc = 1 ;
36563669
3657- if (!to_pack .nr_objects || !window || !depth )
3670+ if (!to_pack .nr_objects || !window || !depth ||
3671+ (!allow_ref_delta && !allow_ofs_delta ))
36583672 return ;
36593673
36603674 if (path_walk )
@@ -4717,7 +4731,7 @@ static int pack_options_allow_reuse(void)
47174731 !ignore_packed_keep_on_disk &&
47184732 !ignore_packed_keep_in_core &&
47194733 (!local || !have_non_local_packs ) &&
4720- !incremental ;
4734+ !incremental && ( allow_ref_delta || allow_ofs_delta ) ;
47214735}
47224736
47234737static int get_object_list_from_bitmap (struct rev_info * revs )
@@ -4739,7 +4753,8 @@ static int get_object_list_from_bitmap(struct rev_info *revs)
47394753 & reuse_packfiles ,
47404754 & reuse_packfiles_nr ,
47414755 & reuse_packfile_bitmap ,
4742- allow_pack_reuse == MULTI_PACK_REUSE );
4756+ allow_pack_reuse == MULTI_PACK_REUSE ,
4757+ allow_ref_delta );
47434758
47444759 if (reuse_packfiles ) {
47454760 reuse_packfile_objects = bitmap_popcount (reuse_packfile_bitmap );
@@ -5170,6 +5185,8 @@ int cmd_pack_objects(int argc,
51705185 N_ ("reuse existing objects" )),
51715186 OPT_BOOL (0 , "delta-base-offset" , & allow_ofs_delta ,
51725187 N_ ("use OFS_DELTA objects" )),
5188+ OPT_BOOL (0 , "ref-delta" , & allow_ref_delta ,
5189+ N_ ("use REF_DELTA objects" )),
51735190 OPT_INTEGER (0 , "threads" , & delta_search_threads ,
51745191 N_ ("use threads when searching for best delta matches" )),
51755192 OPT_BOOL (0 , "non-empty" , & non_empty ,
@@ -5368,7 +5385,7 @@ int cmd_pack_objects(int argc,
53685385 if (unpack_unreachable || keep_unreachable || pack_loose_unreachable )
53695386 use_internal_rev_list = 1 ;
53705387
5371- if (!reuse_object )
5388+ if (!reuse_object || (! allow_ref_delta && ! allow_ofs_delta ) )
53725389 reuse_delta = 0 ;
53735390 if (cfg -> pack_compression_level == -1 )
53745391 cfg -> pack_compression_level = Z_DEFAULT_COMPRESSION ;
0 commit comments