@@ -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
@@ -1685,7 +1693,7 @@ static int add_object_entry(const struct object_id *oid, enum object_type type,
16851693 return 0 ;
16861694 }
16871695
1688- create_object_entry (oid , type , pack_name_hash (name ),
1696+ create_object_entry (oid , type , pack_name_hash_fn (name ),
16891697 exclude , name && no_try_delta (name ),
16901698 found_pack , found_offset );
16911699 return 1 ;
@@ -1899,7 +1907,7 @@ static void add_preferred_base_object(const char *name)
18991907{
19001908 struct pbase_tree * it ;
19011909 size_t cmplen ;
1902- unsigned hash = pack_name_hash (name );
1910+ unsigned hash = pack_name_hash_fn (name );
19031911
19041912 if (!num_preferred_base || check_pbase_path (hash ))
19051913 return ;
@@ -3409,7 +3417,7 @@ static void show_object_pack_hint(struct object *object, const char *name,
34093417 * here using a now in order to perhaps improve the delta selection
34103418 * process.
34113419 */
3412- oe -> hash = pack_name_hash (name );
3420+ oe -> hash = pack_name_hash_fn (name );
34133421 oe -> no_try_delta = name && no_try_delta (name );
34143422
34153423 stdin_packs_hints_nr ++ ;
@@ -3559,7 +3567,7 @@ static void add_cruft_object_entry(const struct object_id *oid, enum object_type
35593567 entry = packlist_find (& to_pack , oid );
35603568 if (entry ) {
35613569 if (name ) {
3562- entry -> hash = pack_name_hash (name );
3570+ entry -> hash = pack_name_hash_fn (name );
35633571 entry -> no_try_delta = no_try_delta (name );
35643572 }
35653573 } else {
@@ -3582,7 +3590,7 @@ static void add_cruft_object_entry(const struct object_id *oid, enum object_type
35823590 return ;
35833591 }
35843592
3585- entry = create_object_entry (oid , type , pack_name_hash (name ),
3593+ entry = create_object_entry (oid , type , pack_name_hash_fn (name ),
35863594 0 , name && no_try_delta (name ),
35873595 pack , offset );
35883596 }
@@ -4431,6 +4439,8 @@ int cmd_pack_objects(int argc,
44314439 OPT_STRING_LIST (0 , "uri-protocol" , & uri_protocols ,
44324440 N_ ("protocol" ),
44334441 N_ ("exclude any configured uploadpack.blobpackfileuri with this protocol" )),
4442+ OPT_BOOL (0 , "full-name-hash" , & use_full_name_hash ,
4443+ N_ ("optimize delta compression across identical path names over time" )),
44344444 OPT_END (),
44354445 };
44364446
@@ -4586,6 +4596,20 @@ int cmd_pack_objects(int argc,
45864596 if (pack_to_stdout || !rev_list_all )
45874597 write_bitmap_index = 0 ;
45884598
4599+ if (use_full_name_hash < 0 )
4600+ use_full_name_hash = git_env_bool ("GIT_TEST_FULL_NAME_HASH" , 0 );
4601+
4602+ if (shallow && use_full_name_hash > 0 &&
4603+ !git_env_bool ("GIT_TEST_USE_FULL_NAME_HASH_WITH_SHALLOW" , 0 )) {
4604+ use_full_name_hash = 0 ;
4605+ warning ("the --full-name-hash option is disabled with the --shallow option" );
4606+ }
4607+
4608+ if (write_bitmap_index && use_full_name_hash > 0 ) {
4609+ warning (_ ("currently, the --full-name-hash option is incompatible with --write-bitmap-index" ));
4610+ use_full_name_hash = 0 ;
4611+ }
4612+
45894613 if (use_delta_islands )
45904614 strvec_push (& rp , "--topo-order" );
45914615
0 commit comments