@@ -267,6 +267,14 @@ struct configured_exclusion {
267267static struct oidmap configured_exclusions ;
268268
269269static struct oidset excluded_by_config ;
270+ static int use_full_name_hash = -1 ;
271+
272+ static inline uint32_t pack_name_hash_fn (const char * name )
273+ {
274+ if (use_full_name_hash )
275+ return pack_full_name_hash (name );
276+ return pack_name_hash (name );
277+ }
270278
271279/*
272280 * stats
@@ -1684,7 +1692,7 @@ static int add_object_entry(const struct object_id *oid, enum object_type type,
16841692 return 0 ;
16851693 }
16861694
1687- create_object_entry (oid , type , pack_name_hash (name ),
1695+ create_object_entry (oid , type , pack_name_hash_fn (name ),
16881696 exclude , name && no_try_delta (name ),
16891697 found_pack , found_offset );
16901698 return 1 ;
@@ -1898,7 +1906,7 @@ static void add_preferred_base_object(const char *name)
18981906{
18991907 struct pbase_tree * it ;
19001908 size_t cmplen ;
1901- unsigned hash = pack_name_hash (name );
1909+ unsigned hash = pack_name_hash_fn (name );
19021910
19031911 if (!num_preferred_base || check_pbase_path (hash ))
19041912 return ;
@@ -3408,7 +3416,7 @@ static void show_object_pack_hint(struct object *object, const char *name,
34083416 * here using a now in order to perhaps improve the delta selection
34093417 * process.
34103418 */
3411- oe -> hash = pack_name_hash (name );
3419+ oe -> hash = pack_name_hash_fn (name );
34123420 oe -> no_try_delta = name && no_try_delta (name );
34133421
34143422 stdin_packs_hints_nr ++ ;
@@ -3558,7 +3566,7 @@ static void add_cruft_object_entry(const struct object_id *oid, enum object_type
35583566 entry = packlist_find (& to_pack , oid );
35593567 if (entry ) {
35603568 if (name ) {
3561- entry -> hash = pack_name_hash (name );
3569+ entry -> hash = pack_name_hash_fn (name );
35623570 entry -> no_try_delta = no_try_delta (name );
35633571 }
35643572 } else {
@@ -3581,7 +3589,7 @@ static void add_cruft_object_entry(const struct object_id *oid, enum object_type
35813589 return ;
35823590 }
35833591
3584- entry = create_object_entry (oid , type , pack_name_hash (name ),
3592+ entry = create_object_entry (oid , type , pack_name_hash_fn (name ),
35853593 0 , name && no_try_delta (name ),
35863594 pack , offset );
35873595 }
@@ -4430,6 +4438,8 @@ int cmd_pack_objects(int argc,
44304438 OPT_STRING_LIST (0 , "uri-protocol" , & uri_protocols ,
44314439 N_ ("protocol" ),
44324440 N_ ("exclude any configured uploadpack.blobpackfileuri with this protocol" )),
4441+ OPT_BOOL (0 , "full-name-hash" , & use_full_name_hash ,
4442+ N_ ("optimize delta compression across identical path names over time" )),
44334443 OPT_END (),
44344444 };
44354445
@@ -4585,6 +4595,20 @@ int cmd_pack_objects(int argc,
45854595 if (pack_to_stdout || !rev_list_all )
45864596 write_bitmap_index = 0 ;
45874597
4598+ if (use_full_name_hash < 0 )
4599+ use_full_name_hash = git_env_bool ("GIT_TEST_FULL_NAME_HASH" , 0 );
4600+
4601+ if (shallow && use_full_name_hash > 0 &&
4602+ !git_env_bool ("GIT_TEST_USE_FULL_NAME_HASH_WITH_SHALLOW" , 0 )) {
4603+ use_full_name_hash = 0 ;
4604+ warning ("the --full-name-hash option is disabled with the --shallow option" );
4605+ }
4606+
4607+ if (write_bitmap_index && use_full_name_hash > 0 ) {
4608+ warning (_ ("currently, the --full-name-hash option is incompatible with --write-bitmap-index" ));
4609+ use_full_name_hash = 0 ;
4610+ }
4611+
45884612 if (use_delta_islands )
45894613 strvec_push (& rp , "--topo-order" );
45904614
0 commit comments