@@ -18,12 +18,16 @@ struct sha1_array {
1818static struct sha1_array good_revs ;
1919static struct sha1_array skipped_revs ;
2020
21- static const char * * rev_argv ;
22- static int rev_argv_nr ;
23- static int rev_argv_alloc ;
24-
2521static const unsigned char * current_bad_sha1 ;
2622
23+ struct argv_array {
24+ const char * * argv ;
25+ int argv_nr ;
26+ int argv_alloc ;
27+ };
28+
29+ struct argv_array rev_argv ;
30+
2731static const char * argv_diff_tree [] = {"diff-tree" , "--pretty" , NULL , NULL };
2832static const char * argv_checkout [] = {"checkout" , "-q" , NULL , "--" , NULL };
2933static const char * argv_show_branch [] = {"show-branch" , NULL , NULL };
@@ -410,13 +414,19 @@ struct commit_list *find_bisection(struct commit_list *list,
410414 return best ;
411415}
412416
413- static void rev_argv_push ( const unsigned char * sha1 , const char * format )
417+ static void argv_array_push ( struct argv_array * array , const char * string )
414418{
415- struct strbuf buf = STRBUF_INIT ;
419+ ALLOC_GROW (array -> argv , array -> argv_nr + 1 , array -> argv_alloc );
420+ array -> argv [array -> argv_nr ++ ] = string ;
421+ }
416422
423+ static void argv_array_push_sha1 (struct argv_array * array ,
424+ const unsigned char * sha1 ,
425+ const char * format )
426+ {
427+ struct strbuf buf = STRBUF_INIT ;
417428 strbuf_addf (& buf , format , sha1_to_hex (sha1 ));
418- ALLOC_GROW (rev_argv , rev_argv_nr + 1 , rev_argv_alloc );
419- rev_argv [rev_argv_nr ++ ] = strbuf_detach (& buf , NULL );
429+ argv_array_push (array , strbuf_detach (& buf , NULL ));
420430}
421431
422432static void sha1_array_push (struct sha1_array * array ,
@@ -445,7 +455,7 @@ static int read_bisect_refs(void)
445455 return for_each_ref_in ("refs/bisect/" , register_ref , NULL );
446456}
447457
448- void read_bisect_paths (void )
458+ void read_bisect_paths (struct argv_array * array )
449459{
450460 struct strbuf str = STRBUF_INIT ;
451461 const char * filename = git_path ("BISECT_NAMES" );
@@ -460,8 +470,8 @@ void read_bisect_paths(void)
460470
461471 strbuf_trim (& str );
462472 quoted = strbuf_detach (& str , NULL );
463- res = sq_dequote_to_argv (quoted , & rev_argv ,
464- & rev_argv_nr , & rev_argv_alloc );
473+ res = sq_dequote_to_argv (quoted , & array -> argv ,
474+ & array -> argv_nr , & array -> argv_alloc );
465475 if (res )
466476 die ("Badly quoted content in file '%s': %s" ,
467477 filename , quoted );
@@ -538,25 +548,16 @@ static void bisect_rev_setup(struct rev_info *revs, const char *prefix)
538548 if (read_bisect_refs ())
539549 die ("reading bisect refs failed" );
540550
541- /* argv[0] will be ignored by setup_revisions */
542- ALLOC_GROW (rev_argv , rev_argv_nr + 1 , rev_argv_alloc );
543- rev_argv [rev_argv_nr ++ ] = xstrdup ("bisect_rev_setup" );
544-
545- rev_argv_push (current_bad_sha1 , "%s" );
546-
551+ /* rev_argv.argv[0] will be ignored by setup_revisions */
552+ argv_array_push (& rev_argv , xstrdup ("bisect_rev_setup" ));
553+ argv_array_push_sha1 (& rev_argv , current_bad_sha1 , "%s" );
547554 for (i = 0 ; i < good_revs .sha1_nr ; i ++ )
548- rev_argv_push (good_revs .sha1 [i ], "^%s" );
549-
550- ALLOC_GROW (rev_argv , rev_argv_nr + 1 , rev_argv_alloc );
551- rev_argv [rev_argv_nr ++ ] = xstrdup ("--" );
552-
553- read_bisect_paths ();
554-
555- ALLOC_GROW (rev_argv , rev_argv_nr + 1 , rev_argv_alloc );
556- rev_argv [rev_argv_nr ++ ] = NULL ;
557-
558- setup_revisions (rev_argv_nr , rev_argv , revs , NULL );
555+ argv_array_push_sha1 (& rev_argv , good_revs .sha1 [i ], "^%s" );
556+ argv_array_push (& rev_argv , xstrdup ("--" ));
557+ read_bisect_paths (& rev_argv );
558+ argv_array_push (& rev_argv , NULL );
559559
560+ setup_revisions (rev_argv .argv_nr , rev_argv .argv , revs , NULL );
560561 revs -> limited = 1 ;
561562}
562563
0 commit comments