@@ -392,18 +392,11 @@ static void create_pack_file(struct upload_pack_data *pack_data)
392
392
die ("git upload-pack: %s" , abort_msg );
393
393
}
394
394
395
- static int got_oid (struct upload_pack_data * data ,
396
- const char * hex , struct object_id * oid )
395
+ static int do_got_oid (struct upload_pack_data * data , const struct object_id * oid )
397
396
{
398
- struct object * o ;
399
397
int we_knew_they_have = 0 ;
398
+ struct object * o = parse_object (the_repository , oid );
400
399
401
- if (get_oid_hex (hex , oid ))
402
- die ("git upload-pack: expected SHA1 object, got '%s'" , hex );
403
- if (!has_object_file (oid ))
404
- return -1 ;
405
-
406
- o = parse_object (the_repository , oid );
407
400
if (!o )
408
401
die ("oops (%s)" , oid_to_hex (oid ));
409
402
if (o -> type == OBJ_COMMIT ) {
@@ -427,6 +420,16 @@ static int got_oid(struct upload_pack_data *data,
427
420
return 0 ;
428
421
}
429
422
423
+ static int got_oid (struct upload_pack_data * data ,
424
+ const char * hex , struct object_id * oid )
425
+ {
426
+ if (get_oid_hex (hex , oid ))
427
+ die ("git upload-pack: expected SHA1 object, got '%s'" , hex );
428
+ if (!has_object_file (oid ))
429
+ return -1 ;
430
+ return do_got_oid (data , oid );
431
+ }
432
+
430
433
static int ok_to_give_up (struct upload_pack_data * data )
431
434
{
432
435
uint32_t min_generation = GENERATION_NUMBER_ZERO ;
@@ -1353,33 +1356,13 @@ static int process_haves(struct upload_pack_data *data, struct oid_array *common
1353
1356
/* Process haves */
1354
1357
for (i = 0 ; i < data -> haves .nr ; i ++ ) {
1355
1358
const struct object_id * oid = & data -> haves .oid [i ];
1356
- struct object * o ;
1357
- int we_knew_they_have = 0 ;
1358
1359
1359
1360
if (!has_object_file (oid ))
1360
1361
continue ;
1361
1362
1362
1363
oid_array_append (common , oid );
1363
1364
1364
- o = parse_object (the_repository , oid );
1365
- if (!o )
1366
- die ("oops (%s)" , oid_to_hex (oid ));
1367
- if (o -> type == OBJ_COMMIT ) {
1368
- struct commit_list * parents ;
1369
- struct commit * commit = (struct commit * )o ;
1370
- if (o -> flags & THEY_HAVE )
1371
- we_knew_they_have = 1 ;
1372
- else
1373
- o -> flags |= THEY_HAVE ;
1374
- if (!data -> oldest_have || (commit -> date < data -> oldest_have ))
1375
- data -> oldest_have = commit -> date ;
1376
- for (parents = commit -> parents ;
1377
- parents ;
1378
- parents = parents -> next )
1379
- parents -> item -> object .flags |= THEY_HAVE ;
1380
- }
1381
- if (!we_knew_they_have )
1382
- add_object_array (o , NULL , & data -> have_obj );
1365
+ do_got_oid (data , oid );
1383
1366
}
1384
1367
1385
1368
return 0 ;
0 commit comments