@@ -1132,6 +1132,8 @@ void upload_pack(struct upload_pack_options *options)
1132
1132
1133
1133
struct upload_pack_data {
1134
1134
struct string_list wanted_refs ;
1135
+ struct object_array want_obj ;
1136
+ struct object_array have_obj ;
1135
1137
struct oid_array haves ;
1136
1138
1137
1139
struct object_array shallows ;
@@ -1157,12 +1159,16 @@ struct upload_pack_data {
1157
1159
static void upload_pack_data_init (struct upload_pack_data * data )
1158
1160
{
1159
1161
struct string_list wanted_refs = STRING_LIST_INIT_DUP ;
1162
+ struct object_array want_obj = OBJECT_ARRAY_INIT ;
1163
+ struct object_array have_obj = OBJECT_ARRAY_INIT ;
1160
1164
struct oid_array haves = OID_ARRAY_INIT ;
1161
1165
struct object_array shallows = OBJECT_ARRAY_INIT ;
1162
1166
struct string_list deepen_not = STRING_LIST_INIT_DUP ;
1163
1167
1164
1168
memset (data , 0 , sizeof (* data ));
1165
1169
data -> wanted_refs = wanted_refs ;
1170
+ data -> want_obj = want_obj ;
1171
+ data -> have_obj = have_obj ;
1166
1172
data -> haves = haves ;
1167
1173
data -> shallows = shallows ;
1168
1174
data -> deepen_not = deepen_not ;
@@ -1172,6 +1178,8 @@ static void upload_pack_data_init(struct upload_pack_data *data)
1172
1178
static void upload_pack_data_clear (struct upload_pack_data * data )
1173
1179
{
1174
1180
string_list_clear (& data -> wanted_refs , 1 );
1181
+ object_array_clear (& data -> want_obj );
1182
+ object_array_clear (& data -> have_obj );
1175
1183
oid_array_clear (& data -> haves );
1176
1184
object_array_clear (& data -> shallows );
1177
1185
string_list_clear (& data -> deepen_not , 0 );
@@ -1256,19 +1264,18 @@ static int parse_have(const char *line, struct oid_array *haves)
1256
1264
}
1257
1265
1258
1266
static void process_args (struct packet_reader * request ,
1259
- struct upload_pack_data * data ,
1260
- struct object_array * want_obj )
1267
+ struct upload_pack_data * data )
1261
1268
{
1262
1269
while (packet_reader_read (request ) == PACKET_READ_NORMAL ) {
1263
1270
const char * arg = request -> line ;
1264
1271
const char * p ;
1265
1272
1266
1273
/* process want */
1267
- if (parse_want (& data -> writer , arg , want_obj ))
1274
+ if (parse_want (& data -> writer , arg , & data -> want_obj ))
1268
1275
continue ;
1269
1276
if (allow_ref_in_want &&
1270
1277
parse_want_ref (& data -> writer , arg , & data -> wanted_refs ,
1271
- want_obj ))
1278
+ & data -> want_obj ))
1272
1279
continue ;
1273
1280
/* process have line */
1274
1281
if (parse_have (arg , & data -> haves ))
@@ -1399,17 +1406,16 @@ static int send_acks(struct packet_writer *writer, struct oid_array *acks,
1399
1406
return 0 ;
1400
1407
}
1401
1408
1402
- static int process_haves_and_send_acks (struct upload_pack_data * data ,
1403
- struct object_array * have_obj ,
1404
- struct object_array * want_obj )
1409
+ static int process_haves_and_send_acks (struct upload_pack_data * data )
1405
1410
{
1406
1411
struct oid_array common = OID_ARRAY_INIT ;
1407
1412
int ret = 0 ;
1408
1413
1409
- process_haves (& data -> haves , & common , have_obj );
1414
+ process_haves (& data -> haves , & common , & data -> have_obj );
1410
1415
if (data -> done ) {
1411
1416
ret = 1 ;
1412
- } else if (send_acks (& data -> writer , & common , have_obj , want_obj )) {
1417
+ } else if (send_acks (& data -> writer , & common ,
1418
+ & data -> have_obj , & data -> want_obj )) {
1413
1419
packet_writer_delim (& data -> writer );
1414
1420
ret = 1 ;
1415
1421
} else {
@@ -1441,8 +1447,7 @@ static void send_wanted_ref_info(struct upload_pack_data *data)
1441
1447
packet_writer_delim (& data -> writer );
1442
1448
}
1443
1449
1444
- static void send_shallow_info (struct upload_pack_data * data ,
1445
- struct object_array * want_obj )
1450
+ static void send_shallow_info (struct upload_pack_data * data )
1446
1451
{
1447
1452
/* No shallow info needs to be sent */
1448
1453
if (!data -> depth && !data -> deepen_rev_list && !data -> shallows .nr &&
@@ -1455,10 +1460,10 @@ static void send_shallow_info(struct upload_pack_data *data,
1455
1460
data -> deepen_rev_list ,
1456
1461
data -> deepen_since , & data -> deepen_not ,
1457
1462
data -> deepen_relative ,
1458
- & data -> shallows , want_obj ) &&
1463
+ & data -> shallows , & data -> want_obj ) &&
1459
1464
is_repository_shallow (the_repository ))
1460
1465
deepen (& data -> writer , INFINITE_DEPTH , data -> deepen_relative ,
1461
- & data -> shallows , want_obj );
1466
+ & data -> shallows , & data -> want_obj );
1462
1467
1463
1468
packet_delim (1 );
1464
1469
}
@@ -1475,8 +1480,6 @@ int upload_pack_v2(struct repository *r, struct argv_array *keys,
1475
1480
{
1476
1481
enum fetch_state state = FETCH_PROCESS_ARGS ;
1477
1482
struct upload_pack_data data ;
1478
- struct object_array have_obj = OBJECT_ARRAY_INIT ;
1479
- struct object_array want_obj = OBJECT_ARRAY_INIT ;
1480
1483
1481
1484
clear_object_flags (ALL_FLAGS );
1482
1485
@@ -1488,9 +1491,9 @@ int upload_pack_v2(struct repository *r, struct argv_array *keys,
1488
1491
while (state != FETCH_DONE ) {
1489
1492
switch (state ) {
1490
1493
case FETCH_PROCESS_ARGS :
1491
- process_args (request , & data , & want_obj );
1494
+ process_args (request , & data );
1492
1495
1493
- if (!want_obj .nr ) {
1496
+ if (!data . want_obj .nr ) {
1494
1497
/*
1495
1498
* Request didn't contain any 'want' lines,
1496
1499
* guess they didn't want anything.
@@ -1510,18 +1513,19 @@ int upload_pack_v2(struct repository *r, struct argv_array *keys,
1510
1513
}
1511
1514
break ;
1512
1515
case FETCH_SEND_ACKS :
1513
- if (process_haves_and_send_acks (& data , & have_obj ,
1514
- & want_obj ))
1516
+ if (process_haves_and_send_acks (& data ))
1515
1517
state = FETCH_SEND_PACK ;
1516
1518
else
1517
1519
state = FETCH_DONE ;
1518
1520
break ;
1519
1521
case FETCH_SEND_PACK :
1520
1522
send_wanted_ref_info (& data );
1521
- send_shallow_info (& data , & want_obj );
1523
+ send_shallow_info (& data );
1522
1524
1523
1525
packet_writer_write (& data .writer , "packfile\n" );
1524
- create_pack_file (& have_obj , & want_obj , & data .filter_options );
1526
+ create_pack_file (& data .have_obj ,
1527
+ & data .want_obj ,
1528
+ & data .filter_options );
1525
1529
state = FETCH_DONE ;
1526
1530
break ;
1527
1531
case FETCH_DONE :
@@ -1530,8 +1534,6 @@ int upload_pack_v2(struct repository *r, struct argv_array *keys,
1530
1534
}
1531
1535
1532
1536
upload_pack_data_clear (& data );
1533
- object_array_clear (& have_obj );
1534
- object_array_clear (& want_obj );
1535
1537
return 0 ;
1536
1538
}
1537
1539
0 commit comments