@@ -18,12 +18,16 @@ struct sha1_array {
18
18
static struct sha1_array good_revs ;
19
19
static struct sha1_array skipped_revs ;
20
20
21
- static const char * * rev_argv ;
22
- static int rev_argv_nr ;
23
- static int rev_argv_alloc ;
24
-
25
21
static const unsigned char * current_bad_sha1 ;
26
22
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
+
27
31
static const char * argv_diff_tree [] = {"diff-tree" , "--pretty" , NULL , NULL };
28
32
static const char * argv_checkout [] = {"checkout" , "-q" , NULL , "--" , NULL };
29
33
static const char * argv_show_branch [] = {"show-branch" , NULL , NULL };
@@ -410,13 +414,19 @@ struct commit_list *find_bisection(struct commit_list *list,
410
414
return best ;
411
415
}
412
416
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 )
414
418
{
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
+ }
416
422
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 ;
417
428
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 ));
420
430
}
421
431
422
432
static void sha1_array_push (struct sha1_array * array ,
@@ -445,7 +455,7 @@ static int read_bisect_refs(void)
445
455
return for_each_ref_in ("refs/bisect/" , register_ref , NULL );
446
456
}
447
457
448
- void read_bisect_paths (void )
458
+ void read_bisect_paths (struct argv_array * array )
449
459
{
450
460
struct strbuf str = STRBUF_INIT ;
451
461
const char * filename = git_path ("BISECT_NAMES" );
@@ -460,8 +470,8 @@ void read_bisect_paths(void)
460
470
461
471
strbuf_trim (& str );
462
472
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 );
465
475
if (res )
466
476
die ("Badly quoted content in file '%s': %s" ,
467
477
filename , quoted );
@@ -538,25 +548,16 @@ static void bisect_rev_setup(struct rev_info *revs, const char *prefix)
538
548
if (read_bisect_refs ())
539
549
die ("reading bisect refs failed" );
540
550
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" );
547
554
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 );
559
559
560
+ setup_revisions (rev_argv .argv_nr , rev_argv .argv , revs , NULL );
560
561
revs -> limited = 1 ;
561
562
}
562
563
0 commit comments