@@ -27,10 +27,9 @@ static int receive_unpack_limit = -1;
27
27
static int transfer_unpack_limit = -1 ;
28
28
static int unpack_limit = 100 ;
29
29
static int report_status ;
30
+ static int prefer_ofs_delta = 1 ;
30
31
static const char * head_name ;
31
-
32
- static char capabilities [] = " report-status delete-refs " ;
33
- static int capabilities_sent ;
32
+ static char * capabilities_to_send ;
34
33
35
34
static enum deny_action parse_deny_action (const char * var , const char * value )
36
35
{
@@ -84,24 +83,29 @@ static int receive_pack_config(const char *var, const char *value, void *cb)
84
83
return 0 ;
85
84
}
86
85
86
+ if (strcmp (var , "repack.usedeltabaseoffset" ) == 0 ) {
87
+ prefer_ofs_delta = git_config_bool (var , value );
88
+ return 0 ;
89
+ }
90
+
87
91
return git_default_config (var , value , cb );
88
92
}
89
93
90
94
static int show_ref (const char * path , const unsigned char * sha1 , int flag , void * cb_data )
91
95
{
92
- if (capabilities_sent )
96
+ if (! capabilities_to_send )
93
97
packet_write (1 , "%s %s\n" , sha1_to_hex (sha1 ), path );
94
98
else
95
99
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 ;
98
102
return 0 ;
99
103
}
100
104
101
105
static void write_head_info (void )
102
106
{
103
107
for_each_ref (show_ref , NULL );
104
- if (! capabilities_sent )
108
+ if (capabilities_to_send )
105
109
show_ref ("capabilities^{}" , null_sha1 , 0 , NULL );
106
110
107
111
}
@@ -687,6 +691,10 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
687
691
else if (0 <= receive_unpack_limit )
688
692
unpack_limit = receive_unpack_limit ;
689
693
694
+ capabilities_to_send = (prefer_ofs_delta ) ?
695
+ " report-status delete-refs ofs-delta " :
696
+ " report-status delete-refs " ;
697
+
690
698
add_alternate_refs ();
691
699
write_head_info ();
692
700
clear_extra_refs ();
0 commit comments