@@ -1195,11 +1195,9 @@ static void add_common(struct strbuf *req_buf, struct oidset *common)
1195
1195
}
1196
1196
1197
1197
static int add_haves (struct fetch_negotiator * negotiator ,
1198
- int seen_ack ,
1199
1198
struct strbuf * req_buf ,
1200
- int * haves_to_send , int * in_vain )
1199
+ int * haves_to_send )
1201
1200
{
1202
- int ret = 0 ;
1203
1201
int haves_added = 0 ;
1204
1202
const struct object_id * oid ;
1205
1203
@@ -1209,17 +1207,10 @@ static int add_haves(struct fetch_negotiator *negotiator,
1209
1207
break ;
1210
1208
}
1211
1209
1212
- * in_vain += haves_added ;
1213
- if (!haves_added || (seen_ack && * in_vain >= MAX_IN_VAIN )) {
1214
- /* Send Done */
1215
- packet_buf_write (req_buf , "done\n" );
1216
- ret = 1 ;
1217
- }
1218
-
1219
1210
/* Increase haves to send on next round */
1220
1211
* haves_to_send = next_flush (1 , * haves_to_send );
1221
1212
1222
- return ret ;
1213
+ return haves_added ;
1223
1214
}
1224
1215
1225
1216
static int send_fetch_request (struct fetch_negotiator * negotiator , int fd_out ,
@@ -1228,7 +1219,8 @@ static int send_fetch_request(struct fetch_negotiator *negotiator, int fd_out,
1228
1219
int * haves_to_send , int * in_vain ,
1229
1220
int sideband_all , int seen_ack )
1230
1221
{
1231
- int ret = 0 ;
1222
+ int haves_added ;
1223
+ int done_sent = 0 ;
1232
1224
const char * hash_name ;
1233
1225
struct strbuf req_buf = STRBUF_INIT ;
1234
1226
@@ -1312,17 +1304,21 @@ static int send_fetch_request(struct fetch_negotiator *negotiator, int fd_out,
1312
1304
/* Add all of the common commits we've found in previous rounds */
1313
1305
add_common (& req_buf , common );
1314
1306
1315
- /* Add initial haves */
1316
- ret = add_haves (negotiator , seen_ack , & req_buf ,
1317
- haves_to_send , in_vain );
1307
+ haves_added = add_haves (negotiator , & req_buf , haves_to_send );
1308
+ * in_vain += haves_added ;
1309
+ if (!haves_added || (seen_ack && * in_vain >= MAX_IN_VAIN )) {
1310
+ /* Send Done */
1311
+ packet_buf_write (& req_buf , "done\n" );
1312
+ done_sent = 1 ;
1313
+ }
1318
1314
1319
1315
/* Send request */
1320
1316
packet_buf_flush (& req_buf );
1321
1317
if (write_in_full (fd_out , req_buf .buf , req_buf .len ) < 0 )
1322
1318
die_errno (_ ("unable to write request to remote" ));
1323
1319
1324
1320
strbuf_release (& req_buf );
1325
- return ret ;
1321
+ return done_sent ;
1326
1322
}
1327
1323
1328
1324
/*
0 commit comments