@@ -27,10 +27,9 @@ static int receive_unpack_limit = -1;
2727static int transfer_unpack_limit = -1 ;
2828static int unpack_limit = 100 ;
2929static int report_status ;
30+ static int prefer_ofs_delta = 1 ;
3031static const char * head_name ;
31-
32- static char capabilities [] = " report-status delete-refs " ;
33- static int capabilities_sent ;
32+ static char * capabilities_to_send ;
3433
3534static enum deny_action parse_deny_action (const char * var , const char * value )
3635{
@@ -84,24 +83,29 @@ static int receive_pack_config(const char *var, const char *value, void *cb)
8483 return 0 ;
8584 }
8685
86+ if (strcmp (var , "repack.usedeltabaseoffset" ) == 0 ) {
87+ prefer_ofs_delta = git_config_bool (var , value );
88+ return 0 ;
89+ }
90+
8791 return git_default_config (var , value , cb );
8892}
8993
9094static int show_ref (const char * path , const unsigned char * sha1 , int flag , void * cb_data )
9195{
92- if (capabilities_sent )
96+ if (! capabilities_to_send )
9397 packet_write (1 , "%s %s\n" , sha1_to_hex (sha1 ), path );
9498 else
9599 packet_write (1 , "%s %s%c%s\n" ,
96- sha1_to_hex (sha1 ), path , 0 , capabilities );
97- capabilities_sent = 1 ;
100+ sha1_to_hex (sha1 ), path , 0 , capabilities_to_send );
101+ capabilities_to_send = NULL ;
98102 return 0 ;
99103}
100104
101105static void write_head_info (void )
102106{
103107 for_each_ref (show_ref , NULL );
104- if (! capabilities_sent )
108+ if (capabilities_to_send )
105109 show_ref ("capabilities^{}" , null_sha1 , 0 , NULL );
106110
107111}
@@ -687,6 +691,10 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
687691 else if (0 <= receive_unpack_limit )
688692 unpack_limit = receive_unpack_limit ;
689693
694+ capabilities_to_send = (prefer_ofs_delta ) ?
695+ " report-status delete-refs ofs-delta " :
696+ " report-status delete-refs " ;
697+
690698 add_alternate_refs ();
691699 write_head_info ();
692700 clear_extra_refs ();
0 commit comments