@@ -37,7 +37,7 @@ static const char *term_good;
3737 * We care just barely enough to avoid recursing for
3838 * non-merge entries.
3939 */
40- static int count_distance (struct commit_list * entry , int first_parent_only )
40+ static int count_distance (struct commit_list * entry , unsigned bisect_flags )
4141{
4242 int nr = 0 ;
4343
@@ -52,10 +52,10 @@ static int count_distance(struct commit_list *entry, int first_parent_only)
5252 commit -> object .flags |= COUNTED ;
5353 p = commit -> parents ;
5454 entry = p ;
55- if (p && !first_parent_only ) {
55+ if (p && !( bisect_flags & BISECT_FIRST_PARENT ) ) {
5656 p = p -> next ;
5757 while (p ) {
58- nr += count_distance (p , first_parent_only );
58+ nr += count_distance (p , bisect_flags );
5959 p = p -> next ;
6060 }
6161 }
@@ -88,15 +88,15 @@ static inline void weight_set(struct commit_list *elem, int weight)
8888 * * commit_weight_at (& commit_weight , elem -> item ) = weight ;
8989}
9090
91- static int count_interesting_parents (struct commit * commit , int first_parent_only )
91+ static int count_interesting_parents (struct commit * commit , unsigned bisect_flags )
9292{
9393 struct commit_list * p ;
9494 int count ;
9595
9696 for (count = 0 , p = commit -> parents ; p ; p = p -> next ) {
9797 if (!(p -> item -> object .flags & UNINTERESTING ))
9898 count ++ ;
99- if (first_parent_only )
99+ if (bisect_flags & BISECT_FIRST_PARENT )
100100 break ;
101101 }
102102 return count ;
@@ -260,7 +260,7 @@ static struct commit_list *best_bisection_sorted(struct commit_list *list, int n
260260 */
261261static struct commit_list * do_find_bisection (struct commit_list * list ,
262262 int nr , int * weights ,
263- int find_all , int first_parent_only )
263+ unsigned bisect_flags )
264264{
265265 int n , counted ;
266266 struct commit_list * p ;
@@ -272,7 +272,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
272272 unsigned flags = commit -> object .flags ;
273273
274274 * commit_weight_at (& commit_weight , p -> item ) = & weights [n ++ ];
275- switch (count_interesting_parents (commit , first_parent_only )) {
275+ switch (count_interesting_parents (commit , bisect_flags )) {
276276 case 0 :
277277 if (!(flags & TREESAME )) {
278278 weight_set (p , 1 );
@@ -315,11 +315,11 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
315315 continue ;
316316 if (weight (p ) != -2 )
317317 continue ;
318- weight_set (p , count_distance (p , first_parent_only ));
318+ weight_set (p , count_distance (p , bisect_flags ));
319319 clear_distance (list );
320320
321321 /* Does it happen to be at exactly half-way? */
322- if (!find_all && halfway (p , nr ))
322+ if (!( bisect_flags & BISECT_FIND_ALL ) && halfway (p , nr ))
323323 return p ;
324324 counted ++ ;
325325 }
@@ -342,7 +342,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
342342 for (q = p -> item -> parents ; q ; q = q -> next ) {
343343 if (!(q -> item -> object .flags & UNINTERESTING ) && 0 <= weight (q )) {
344344 break ;
345- } else if (first_parent_only ) {
345+ } else if (bisect_flags & BISECT_FIRST_PARENT ) {
346346 q = NULL ;
347347 break ;
348348 }
@@ -365,21 +365,21 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
365365 weight_set (p , weight (q ));
366366
367367 /* Does it happen to be at exactly half-way? */
368- if (!find_all && halfway (p , nr ))
368+ if (!( bisect_flags & BISECT_FIND_ALL ) && halfway (p , nr ))
369369 return p ;
370370 }
371371 }
372372
373373 show_list ("bisection 2 counted all" , counted , nr , list );
374374
375- if (!find_all )
375+ if (!( bisect_flags & BISECT_FIND_ALL ) )
376376 return best_bisection (list , nr );
377377 else
378378 return best_bisection_sorted (list , nr );
379379}
380380
381381void find_bisection (struct commit_list * * commit_list , int * reaches ,
382- int * all , int find_all , int first_parent_only )
382+ int * all , unsigned bisect_flags )
383383{
384384 int nr , on_list ;
385385 struct commit_list * list , * p , * best , * next , * last ;
@@ -415,9 +415,9 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
415415 weights = xcalloc (on_list , sizeof (* weights ));
416416
417417 /* Do the real work of finding bisection commit. */
418- best = do_find_bisection (list , nr , weights , find_all , first_parent_only );
418+ best = do_find_bisection (list , nr , weights , bisect_flags );
419419 if (best ) {
420- if (!find_all ) {
420+ if (!( bisect_flags & BISECT_FIND_ALL ) ) {
421421 list -> item = best -> item ;
422422 free_commit_list (list -> next );
423423 best = list ;
@@ -1007,23 +1007,30 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix, int
10071007 enum bisect_error res = BISECT_OK ;
10081008 struct object_id * bisect_rev ;
10091009 char * steps_msg ;
1010- int first_parent_only = read_first_parent_option () ;
1010+ unsigned bisect_flags = 0 ;
10111011
10121012 read_bisect_terms (& term_bad , & term_good );
10131013 if (read_bisect_refs ())
10141014 die (_ ("reading bisect refs failed" ));
10151015
1016+ if (read_first_parent_option ())
1017+ bisect_flags |= BISECT_FIRST_PARENT ;
1018+
1019+ if (!!skipped_revs .nr )
1020+ bisect_flags |= BISECT_FIND_ALL ;
1021+
10161022 res = check_good_are_ancestors_of_bad (r , prefix , no_checkout );
10171023 if (res )
10181024 return res ;
10191025
10201026 bisect_rev_setup (r , & revs , prefix , "%s" , "^%s" , 1 );
1021- revs .first_parent_only = first_parent_only ;
1027+
1028+ revs .first_parent_only = !!(bisect_flags & BISECT_FIRST_PARENT );
10221029 revs .limited = 1 ;
10231030
10241031 bisect_common (& revs );
10251032
1026- find_bisection (& revs .commits , & reaches , & all , !! skipped_revs . nr , first_parent_only );
1033+ find_bisection (& revs .commits , & reaches , & all , bisect_flags );
10271034 revs .commits = managed_skipped (revs .commits , & tried );
10281035
10291036 if (!revs .commits ) {
0 commit comments