@@ -55,10 +55,6 @@ static unsigned int allow_unadvertised_object_request;
55
55
static int shallow_nr ;
56
56
static struct object_array extra_edge_obj ;
57
57
static int keepalive = 5 ;
58
- /* 0 for no sideband,
59
- * otherwise maximum packet size (up to 65520 bytes).
60
- */
61
- static int use_sideband ;
62
58
static const char * pack_objects_hook ;
63
59
64
60
static int filter_capability_requested ;
@@ -87,6 +83,9 @@ struct upload_pack_data {
87
83
88
84
unsigned int timeout ; /* v0 only */
89
85
86
+ /* 0 for no sideband, otherwise DEFAULT_PACKET_MAX or LARGE_PACKET_MAX */
87
+ int use_sideband ;
88
+
90
89
struct list_objects_filter_options filter_options ;
91
90
92
91
struct packet_writer writer ;
@@ -141,7 +140,8 @@ static void reset_timeout(unsigned int timeout)
141
140
alarm (timeout );
142
141
}
143
142
144
- static void send_client_data (int fd , const char * data , ssize_t sz )
143
+ static void send_client_data (int fd , const char * data , ssize_t sz ,
144
+ int use_sideband )
145
145
{
146
146
if (use_sideband ) {
147
147
send_sideband (1 , fd , data , sz , use_sideband );
@@ -290,7 +290,8 @@ static void create_pack_file(struct upload_pack_data *pack_data)
290
290
sz = xread (pack_objects .err , progress ,
291
291
sizeof (progress ));
292
292
if (0 < sz )
293
- send_client_data (2 , progress , sz );
293
+ send_client_data (2 , progress , sz ,
294
+ pack_data -> use_sideband );
294
295
else if (sz == 0 ) {
295
296
close (pack_objects .err );
296
297
pack_objects .err = -1 ;
@@ -333,7 +334,8 @@ static void create_pack_file(struct upload_pack_data *pack_data)
333
334
}
334
335
else
335
336
buffered = -1 ;
336
- send_client_data (1 , data , sz );
337
+ send_client_data (1 , data , sz ,
338
+ pack_data -> use_sideband );
337
339
}
338
340
339
341
/*
@@ -346,7 +348,7 @@ static void create_pack_file(struct upload_pack_data *pack_data)
346
348
* protocol to say anything, so those clients are just out of
347
349
* luck.
348
350
*/
349
- if (!ret && use_sideband ) {
351
+ if (!ret && pack_data -> use_sideband ) {
350
352
static const char buf [] = "0005\1" ;
351
353
write_or_die (1 , buf , 5 );
352
354
}
@@ -360,15 +362,17 @@ static void create_pack_file(struct upload_pack_data *pack_data)
360
362
/* flush the data */
361
363
if (0 <= buffered ) {
362
364
data [0 ] = buffered ;
363
- send_client_data (1 , data , 1 );
365
+ send_client_data (1 , data , 1 ,
366
+ pack_data -> use_sideband );
364
367
fprintf (stderr , "flushed.\n" );
365
368
}
366
- if (use_sideband )
369
+ if (pack_data -> use_sideband )
367
370
packet_flush (1 );
368
371
return ;
369
372
370
373
fail :
371
- send_client_data (3 , abort_msg , sizeof (abort_msg ));
374
+ send_client_data (3 , abort_msg , sizeof (abort_msg ),
375
+ pack_data -> use_sideband );
372
376
die ("git upload-pack: %s" , abort_msg );
373
377
}
374
378
@@ -964,9 +968,9 @@ static void receive_needs(struct upload_pack_data *data,
964
968
if (parse_feature_request (features , "ofs-delta" ))
965
969
data -> use_ofs_delta = 1 ;
966
970
if (parse_feature_request (features , "side-band-64k" ))
967
- use_sideband = LARGE_PACKET_MAX ;
971
+ data -> use_sideband = LARGE_PACKET_MAX ;
968
972
else if (parse_feature_request (features , "side-band" ))
969
- use_sideband = DEFAULT_PACKET_MAX ;
973
+ data -> use_sideband = DEFAULT_PACKET_MAX ;
970
974
if (parse_feature_request (features , "no-progress" ))
971
975
data -> no_progress = 1 ;
972
976
if (parse_feature_request (features , "include-tag" ))
@@ -1001,7 +1005,7 @@ static void receive_needs(struct upload_pack_data *data,
1001
1005
if (has_non_tip )
1002
1006
check_non_tip (data );
1003
1007
1004
- if (!use_sideband && data -> daemon_mode )
1008
+ if (!data -> use_sideband && data -> daemon_mode )
1005
1009
data -> no_progress = 1 ;
1006
1010
1007
1011
if (data -> depth == 0 && !data -> deepen_rev_list && data -> shallows .nr == 0 )
@@ -1486,7 +1490,7 @@ int upload_pack_v2(struct repository *r, struct argv_array *keys,
1486
1490
git_config (upload_pack_config , NULL );
1487
1491
1488
1492
upload_pack_data_init (& data );
1489
- use_sideband = LARGE_PACKET_MAX ;
1493
+ data . use_sideband = LARGE_PACKET_MAX ;
1490
1494
1491
1495
while (state != FETCH_DONE ) {
1492
1496
switch (state ) {
0 commit comments