11
11
#include "transport.h"
12
12
#include "string-list.h"
13
13
#include "sha1-array.h"
14
+ #include "connected.h"
14
15
15
16
static const char receive_pack_usage [] = "git receive-pack <git-dir>" ;
16
17
@@ -546,6 +547,43 @@ static void check_aliased_updates(struct command *commands)
546
547
string_list_clear (& ref_list , 0 );
547
548
}
548
549
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
+
549
587
static void execute_commands (struct command * commands , const char * unpacker_error )
550
588
{
551
589
struct command * cmd ;
@@ -557,6 +595,11 @@ static void execute_commands(struct command *commands, const char *unpacker_erro
557
595
return ;
558
596
}
559
597
598
+ cmd = commands ;
599
+ if (check_everything_connected (iterate_receive_command_list ,
600
+ 0 , & cmd ))
601
+ set_connectivity_errors (commands );
602
+
560
603
if (run_receive_hook (commands , pre_receive_hook )) {
561
604
for (cmd = commands ; cmd ; cmd = cmd -> next )
562
605
cmd -> error_string = "pre-receive hook declined" ;
0 commit comments