1111#include "transport.h"
1212#include "string-list.h"
1313#include "sha1-array.h"
14+ #include "connected.h"
1415
1516static const char receive_pack_usage [] = "git receive-pack <git-dir>" ;
1617
@@ -546,6 +547,43 @@ static void check_aliased_updates(struct command *commands)
546547 string_list_clear (& ref_list , 0 );
547548}
548549
550+ static int command_singleton_iterator (void * cb_data , unsigned char sha1 [20 ])
551+ {
552+ struct command * * cmd_list = cb_data ;
553+ struct command * cmd = * cmd_list ;
554+
555+ if (!cmd )
556+ return -1 ; /* end of list */
557+ * cmd_list = NULL ; /* this returns only one */
558+ hashcpy (sha1 , cmd -> new_sha1 );
559+ return 0 ;
560+ }
561+
562+ static void set_connectivity_errors (struct command * commands )
563+ {
564+ struct command * cmd ;
565+
566+ for (cmd = commands ; cmd ; cmd = cmd -> next ) {
567+ struct command * singleton = cmd ;
568+ if (!check_everything_connected (command_singleton_iterator ,
569+ 0 , & singleton ))
570+ continue ;
571+ cmd -> error_string = "missing necessary objects" ;
572+ }
573+ }
574+
575+ static int iterate_receive_command_list (void * cb_data , unsigned char sha1 [20 ])
576+ {
577+ struct command * * cmd_list = cb_data ;
578+ struct command * cmd = * cmd_list ;
579+
580+ if (!cmd )
581+ return -1 ; /* end of list */
582+ * cmd_list = cmd -> next ;
583+ hashcpy (sha1 , cmd -> new_sha1 );
584+ return 0 ;
585+ }
586+
549587static void execute_commands (struct command * commands , const char * unpacker_error )
550588{
551589 struct command * cmd ;
@@ -557,6 +595,11 @@ static void execute_commands(struct command *commands, const char *unpacker_erro
557595 return ;
558596 }
559597
598+ cmd = commands ;
599+ if (check_everything_connected (iterate_receive_command_list ,
600+ 0 , & cmd ))
601+ set_connectivity_errors (commands );
602+
560603 if (run_receive_hook (commands , pre_receive_hook )) {
561604 for (cmd = commands ; cmd ; cmd = cmd -> next )
562605 cmd -> error_string = "pre-receive hook declined" ;
0 commit comments