@@ -507,33 +507,39 @@ static void free_submodules_sha1s(struct string_list *submodules)
507
507
string_list_clear (submodules , 1 );
508
508
}
509
509
510
- int find_unpushed_submodules (unsigned char new_sha1 [20 ],
510
+ static void append_hash_to_argv (const unsigned char sha1 [20 ],
511
+ void * data )
512
+ {
513
+ struct argv_array * argv = (struct argv_array * ) data ;
514
+ argv_array_push (argv , sha1_to_hex (sha1 ));
515
+ }
516
+
517
+ int find_unpushed_submodules (struct sha1_array * hashes ,
511
518
const char * remotes_name , struct string_list * needs_pushing )
512
519
{
513
520
struct rev_info rev ;
514
521
struct commit * commit ;
515
- const char * argv [] = {NULL , NULL , "--not" , "NULL" , NULL };
516
- int argc = ARRAY_SIZE (argv ) - 1 , i ;
517
- char * sha1_copy ;
522
+ int i ;
518
523
struct string_list submodules = STRING_LIST_INIT_DUP ;
524
+ struct argv_array argv = ARGV_ARRAY_INIT ;
519
525
520
- struct strbuf remotes_arg = STRBUF_INIT ;
521
-
522
- strbuf_addf (& remotes_arg , "--remotes=%s" , remotes_name );
523
526
init_revisions (& rev , NULL );
524
- sha1_copy = xstrdup (sha1_to_hex (new_sha1 ));
525
- argv [1 ] = sha1_copy ;
526
- argv [3 ] = remotes_arg .buf ;
527
- setup_revisions (argc , argv , & rev , NULL );
527
+
528
+ /* argv.argv[0] will be ignored by setup_revisions */
529
+ argv_array_push (& argv , "find_unpushed_submodules" );
530
+ sha1_array_for_each_unique (hashes , append_hash_to_argv , & argv );
531
+ argv_array_push (& argv , "--not" );
532
+ argv_array_pushf (& argv , "--remotes=%s" , remotes_name );
533
+
534
+ setup_revisions (argv .argc , argv .argv , & rev , NULL );
528
535
if (prepare_revision_walk (& rev ))
529
536
die ("revision walk setup failed" );
530
537
531
538
while ((commit = get_revision (& rev )) != NULL )
532
539
find_unpushed_submodule_commits (commit , & submodules );
533
540
534
541
reset_revision_walk ();
535
- free (sha1_copy );
536
- strbuf_release (& remotes_arg );
542
+ argv_array_clear (& argv );
537
543
538
544
for (i = 0 ; i < submodules .nr ; i ++ ) {
539
545
struct string_list_item * item = & submodules .items [i ];
@@ -571,12 +577,12 @@ static int push_submodule(const char *path)
571
577
return 1 ;
572
578
}
573
579
574
- int push_unpushed_submodules (unsigned char new_sha1 [ 20 ] , const char * remotes_name )
580
+ int push_unpushed_submodules (struct sha1_array * hashes , const char * remotes_name )
575
581
{
576
582
int i , ret = 1 ;
577
583
struct string_list needs_pushing = STRING_LIST_INIT_DUP ;
578
584
579
- if (!find_unpushed_submodules (new_sha1 , remotes_name , & needs_pushing ))
585
+ if (!find_unpushed_submodules (hashes , remotes_name , & needs_pushing ))
580
586
return 1 ;
581
587
582
588
for (i = 0 ; i < needs_pushing .nr ; i ++ ) {
0 commit comments