@@ -451,7 +451,7 @@ static int is_our_ref(struct object *o)
451
451
return o -> flags & ((allow_hidden_ref ? HIDDEN_REF : 0 ) | OUR_REF );
452
452
}
453
453
454
- static void check_non_tip ( void )
454
+ static int has_unreachable ( struct object_array * src )
455
455
{
456
456
static const char * argv [] = {
457
457
"rev-list" , "--stdin" , NULL ,
@@ -461,14 +461,6 @@ static void check_non_tip(void)
461
461
char namebuf [42 ]; /* ^ + SHA-1 + LF */
462
462
int i ;
463
463
464
- /*
465
- * In the normal in-process case without
466
- * uploadpack.allowReachableSHA1InWant,
467
- * non-tip requests can never happen.
468
- */
469
- if (!stateless_rpc && !(allow_unadvertised_object_request & ALLOW_REACHABLE_SHA1 ))
470
- goto error ;
471
-
472
464
cmd .argv = argv ;
473
465
cmd .git_cmd = 1 ;
474
466
cmd .no_stderr = 1 ;
@@ -498,8 +490,8 @@ static void check_non_tip(void)
498
490
goto error ;
499
491
}
500
492
namebuf [40 ] = '\n' ;
501
- for (i = 0 ; i < want_obj . nr ; i ++ ) {
502
- o = want_obj . objects [i ].item ;
493
+ for (i = 0 ; i < src -> nr ; i ++ ) {
494
+ o = src -> objects [i ].item ;
503
495
if (is_our_ref (o ))
504
496
continue ;
505
497
memcpy (namebuf , oid_to_hex (& o -> oid ), GIT_SHA1_HEXSZ );
@@ -530,7 +522,7 @@ static void check_non_tip(void)
530
522
sigchain_pop (SIGPIPE );
531
523
532
524
/* All the non-tip ones are ancestors of what we advertised */
533
- return ;
525
+ return 0 ;
534
526
535
527
error :
536
528
sigchain_pop (SIGPIPE );
@@ -539,10 +531,28 @@ static void check_non_tip(void)
539
531
close (cmd .in );
540
532
if (cmd .out >= 0 )
541
533
close (cmd .out );
534
+ return 1 ;
535
+ }
542
536
537
+ static void check_non_tip (void )
538
+ {
539
+ int i ;
540
+
541
+ /*
542
+ * In the normal in-process case without
543
+ * uploadpack.allowReachableSHA1InWant,
544
+ * non-tip requests can never happen.
545
+ */
546
+ if (!stateless_rpc && !(allow_unadvertised_object_request & ALLOW_REACHABLE_SHA1 ))
547
+ goto error ;
548
+ if (!has_unreachable (& want_obj ))
549
+ /* All the non-tip ones are ancestors of what we advertised */
550
+ return ;
551
+
552
+ error :
543
553
/* Pick one of them (we know there at least is one) */
544
554
for (i = 0 ; i < want_obj .nr ; i ++ ) {
545
- o = want_obj .objects [i ].item ;
555
+ struct object * o = want_obj .objects [i ].item ;
546
556
if (!is_our_ref (o ))
547
557
die ("git upload-pack: not our ref %s" ,
548
558
oid_to_hex (& o -> oid ));
0 commit comments