@@ -648,29 +648,31 @@ static struct commit_list *managed_skipped(struct commit_list *list,
648648}
649649
650650static void bisect_rev_setup (struct repository * r , struct rev_info * revs ,
651+ struct strvec * rev_argv ,
651652 const char * prefix ,
652653 const char * bad_format , const char * good_format ,
653654 int read_paths )
654655{
655- struct strvec rev_argv = STRVEC_INIT ;
656+ struct setup_revision_opt opt = {
657+ .free_removed_argv_elements = 1 ,
658+ };
656659 int i ;
657660
658661 repo_init_revisions (r , revs , prefix );
659662 revs -> abbrev = 0 ;
660663 revs -> commit_format = CMIT_FMT_UNSPECIFIED ;
661664
662665 /* rev_argv.argv[0] will be ignored by setup_revisions */
663- strvec_push (& rev_argv , "bisect_rev_setup" );
664- strvec_pushf (& rev_argv , bad_format , oid_to_hex (current_bad_oid ));
666+ strvec_push (rev_argv , "bisect_rev_setup" );
667+ strvec_pushf (rev_argv , bad_format , oid_to_hex (current_bad_oid ));
665668 for (i = 0 ; i < good_revs .nr ; i ++ )
666- strvec_pushf (& rev_argv , good_format ,
669+ strvec_pushf (rev_argv , good_format ,
667670 oid_to_hex (good_revs .oid + i ));
668- strvec_push (& rev_argv , "--" );
671+ strvec_push (rev_argv , "--" );
669672 if (read_paths )
670- read_bisect_paths (& rev_argv );
673+ read_bisect_paths (rev_argv );
671674
672- setup_revisions (rev_argv .nr , rev_argv .v , revs , NULL );
673- /* XXX leak rev_argv, as "revs" may still be pointing to it */
675+ setup_revisions (rev_argv -> nr , rev_argv -> v , revs , & opt );
674676}
675677
676678static void bisect_common (struct rev_info * revs )
@@ -873,10 +875,11 @@ static enum bisect_error check_merge_bases(int rev_nr, struct commit **rev, int
873875static int check_ancestors (struct repository * r , int rev_nr ,
874876 struct commit * * rev , const char * prefix )
875877{
878+ struct strvec rev_argv = STRVEC_INIT ;
876879 struct rev_info revs ;
877880 int res ;
878881
879- bisect_rev_setup (r , & revs , prefix , "^%s" , "%s" , 0 );
882+ bisect_rev_setup (r , & revs , & rev_argv , prefix , "^%s" , "%s" , 0 );
880883
881884 bisect_common (& revs );
882885 res = (revs .commits != NULL );
@@ -885,6 +888,7 @@ static int check_ancestors(struct repository *r, int rev_nr,
885888 clear_commit_marks_many (rev_nr , rev , ALL_REV_FLAGS );
886889
887890 release_revisions (& revs );
891+ strvec_clear (& rev_argv );
888892 return res ;
889893}
890894
@@ -1010,6 +1014,7 @@ void read_bisect_terms(const char **read_bad, const char **read_good)
10101014 */
10111015enum bisect_error bisect_next_all (struct repository * r , const char * prefix )
10121016{
1017+ struct strvec rev_argv = STRVEC_INIT ;
10131018 struct rev_info revs = REV_INFO_INIT ;
10141019 struct commit_list * tried ;
10151020 int reaches = 0 , all = 0 , nr , steps ;
@@ -1037,7 +1042,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
10371042 if (res )
10381043 goto cleanup ;
10391044
1040- bisect_rev_setup (r , & revs , prefix , "%s" , "^%s" , 1 );
1045+ bisect_rev_setup (r , & revs , & rev_argv , prefix , "%s" , "^%s" , 1 );
10411046
10421047 revs .first_parent_only = !!(bisect_flags & FIND_BISECTION_FIRST_PARENT_ONLY );
10431048 revs .limited = 1 ;
@@ -1054,7 +1059,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
10541059 */
10551060 res = error_if_skipped_commits (tried , NULL );
10561061 if (res < 0 )
1057- return res ;
1062+ goto cleanup ;
10581063 printf (_ ("%s was both %s and %s\n" ),
10591064 oid_to_hex (current_bad_oid ),
10601065 term_good ,
@@ -1112,6 +1117,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
11121117 res = bisect_checkout (bisect_rev , no_checkout );
11131118cleanup :
11141119 release_revisions (& revs );
1120+ strvec_clear (& rev_argv );
11151121 return res ;
11161122}
11171123
0 commit comments