@@ -451,7 +451,7 @@ static int is_our_ref(struct object *o)
451451 return o -> flags & ((allow_hidden_ref ? HIDDEN_REF : 0 ) | OUR_REF );
452452}
453453
454- static void check_non_tip ( void )
454+ static int has_unreachable ( struct object_array * src )
455455{
456456 static const char * argv [] = {
457457 "rev-list" , "--stdin" , NULL ,
@@ -461,14 +461,6 @@ static void check_non_tip(void)
461461 char namebuf [42 ]; /* ^ + SHA-1 + LF */
462462 int i ;
463463
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-
472464 cmd .argv = argv ;
473465 cmd .git_cmd = 1 ;
474466 cmd .no_stderr = 1 ;
@@ -498,8 +490,8 @@ static void check_non_tip(void)
498490 goto error ;
499491 }
500492 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 ;
503495 if (is_our_ref (o ))
504496 continue ;
505497 memcpy (namebuf , oid_to_hex (& o -> oid ), GIT_SHA1_HEXSZ );
@@ -530,7 +522,7 @@ static void check_non_tip(void)
530522 sigchain_pop (SIGPIPE );
531523
532524 /* All the non-tip ones are ancestors of what we advertised */
533- return ;
525+ return 0 ;
534526
535527error :
536528 sigchain_pop (SIGPIPE );
@@ -539,10 +531,28 @@ static void check_non_tip(void)
539531 close (cmd .in );
540532 if (cmd .out >= 0 )
541533 close (cmd .out );
534+ return 1 ;
535+ }
542536
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 :
543553 /* Pick one of them (we know there at least is one) */
544554 for (i = 0 ; i < want_obj .nr ; i ++ ) {
545- o = want_obj .objects [i ].item ;
555+ struct object * o = want_obj .objects [i ].item ;
546556 if (!is_our_ref (o ))
547557 die ("git upload-pack: not our ref %s" ,
548558 oid_to_hex (& o -> oid ));
0 commit comments