19
19
#include "ll-merge.h"
20
20
#include "resolve-undo.h"
21
21
#include "submodule.h"
22
+ #include "argv-array.h"
22
23
23
24
static const char * const checkout_usage [] = {
24
25
"git checkout [options] <branch>" ,
@@ -588,24 +589,12 @@ static void update_refs_for_switch(struct checkout_opts *opts,
588
589
report_tracking (new );
589
590
}
590
591
591
- struct rev_list_args {
592
- int argc ;
593
- int alloc ;
594
- const char * * argv ;
595
- };
596
-
597
- static void add_one_rev_list_arg (struct rev_list_args * args , const char * s )
598
- {
599
- ALLOC_GROW (args -> argv , args -> argc + 1 , args -> alloc );
600
- args -> argv [args -> argc ++ ] = s ;
601
- }
602
-
603
592
static int add_one_ref_to_rev_list_arg (const char * refname ,
604
593
const unsigned char * sha1 ,
605
594
int flags ,
606
595
void * cb_data )
607
596
{
608
- add_one_rev_list_arg (cb_data , refname );
597
+ argv_array_push (cb_data , refname );
609
598
return 0 ;
610
599
}
611
600
@@ -684,15 +673,14 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
684
673
*/
685
674
static void orphaned_commit_warning (struct commit * commit )
686
675
{
687
- struct rev_list_args args = { 0 , 0 , NULL } ;
676
+ struct argv_array args = ARGV_ARRAY_INIT ;
688
677
struct rev_info revs ;
689
678
690
- add_one_rev_list_arg (& args , "(internal)" );
691
- add_one_rev_list_arg (& args , sha1_to_hex (commit -> object .sha1 ));
692
- add_one_rev_list_arg (& args , "--not" );
679
+ argv_array_push (& args , "(internal)" );
680
+ argv_array_push (& args , sha1_to_hex (commit -> object .sha1 ));
681
+ argv_array_push (& args , "--not" );
693
682
for_each_ref (add_one_ref_to_rev_list_arg , & args );
694
- add_one_rev_list_arg (& args , "--" );
695
- add_one_rev_list_arg (& args , NULL );
683
+ argv_array_push (& args , "--" );
696
684
697
685
init_revisions (& revs , NULL );
698
686
if (setup_revisions (args .argc - 1 , args .argv , & revs , NULL ) != 1 )
@@ -704,6 +692,7 @@ static void orphaned_commit_warning(struct commit *commit)
704
692
else
705
693
describe_detached_head (_ ("Previous HEAD position was" ), commit );
706
694
695
+ argv_array_clear (& args );
707
696
clear_commit_marks (commit , -1 );
708
697
for_each_ref (clear_commit_marks_from_one_ref , NULL );
709
698
}
0 commit comments