@@ -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
@@ -1699,7 +1707,7 @@ static int add_object_entry(const struct object_id *oid, enum object_type type,
16991707 return 0 ;
17001708 }
17011709
1702- create_object_entry (oid , type , pack_name_hash (name ),
1710+ create_object_entry (oid , type , pack_name_hash_fn (name ),
17031711 exclude , name && no_try_delta (name ),
17041712 found_pack , found_offset );
17051713 return 1 ;
@@ -1913,7 +1921,7 @@ static void add_preferred_base_object(const char *name)
19131921{
19141922 struct pbase_tree * it ;
19151923 size_t cmplen ;
1916- unsigned hash = pack_name_hash (name );
1924+ unsigned hash = pack_name_hash_fn (name );
19171925
19181926 if (!num_preferred_base || check_pbase_path (hash ))
19191927 return ;
@@ -3423,7 +3431,7 @@ static void show_object_pack_hint(struct object *object, const char *name,
34233431 * here using a now in order to perhaps improve the delta selection
34243432 * process.
34253433 */
3426- oe -> hash = pack_name_hash (name );
3434+ oe -> hash = pack_name_hash_fn (name );
34273435 oe -> no_try_delta = name && no_try_delta (name );
34283436
34293437 stdin_packs_hints_nr ++ ;
@@ -3573,7 +3581,7 @@ static void add_cruft_object_entry(const struct object_id *oid, enum object_type
35733581 entry = packlist_find (& to_pack , oid );
35743582 if (entry ) {
35753583 if (name ) {
3576- entry -> hash = pack_name_hash (name );
3584+ entry -> hash = pack_name_hash_fn (name );
35773585 entry -> no_try_delta = no_try_delta (name );
35783586 }
35793587 } else {
@@ -3596,7 +3604,7 @@ static void add_cruft_object_entry(const struct object_id *oid, enum object_type
35963604 return ;
35973605 }
35983606
3599- entry = create_object_entry (oid , type , pack_name_hash (name ),
3607+ entry = create_object_entry (oid , type , pack_name_hash_fn (name ),
36003608 0 , name && no_try_delta (name ),
36013609 pack , offset );
36023610 }
@@ -4445,6 +4453,8 @@ int cmd_pack_objects(int argc,
44454453 OPT_STRING_LIST (0 , "uri-protocol" , & uri_protocols ,
44464454 N_ ("protocol" ),
44474455 N_ ("exclude any configured uploadpack.blobpackfileuri with this protocol" )),
4456+ OPT_BOOL (0 , "full-name-hash" , & use_full_name_hash ,
4457+ N_ ("optimize delta compression across identical path names over time" )),
44484458 OPT_END (),
44494459 };
44504460
@@ -4600,6 +4610,20 @@ int cmd_pack_objects(int argc,
46004610 if (pack_to_stdout || !rev_list_all )
46014611 write_bitmap_index = 0 ;
46024612
4613+ if (use_full_name_hash < 0 )
4614+ use_full_name_hash = git_env_bool ("GIT_TEST_FULL_NAME_HASH" , 0 );
4615+
4616+ if (shallow && use_full_name_hash > 0 &&
4617+ !git_env_bool ("GIT_TEST_USE_FULL_NAME_HASH_WITH_SHALLOW" , 0 )) {
4618+ use_full_name_hash = 0 ;
4619+ warning ("the --full-name-hash option is disabled with the --shallow option" );
4620+ }
4621+
4622+ if (write_bitmap_index && use_full_name_hash > 0 ) {
4623+ warning (_ ("currently, the --full-name-hash option is incompatible with --write-bitmap-index" ));
4624+ use_full_name_hash = 0 ;
4625+ }
4626+
46034627 if (use_delta_islands )
46044628 strvec_push (& rp , "--topo-order" );
46054629
0 commit comments