@@ -89,15 +89,15 @@ static inline void weight_set(struct commit_list *elem, int weight)
89
89
* * commit_weight_at (& commit_weight , elem -> item ) = weight ;
90
90
}
91
91
92
- static int count_interesting_parents (struct commit * commit , int first_parent_only )
92
+ static int count_interesting_parents (struct commit * commit , unsigned bisect_flags )
93
93
{
94
94
struct commit_list * p ;
95
95
int count ;
96
96
97
97
for (count = 0 , p = commit -> parents ; p ; p = p -> next ) {
98
98
if (!(p -> item -> object .flags & UNINTERESTING ))
99
99
count ++ ;
100
- if (first_parent_only )
100
+ if (bisect_flags & FIND_BISECTION_FIRST_PARENT_ONLY )
101
101
break ;
102
102
}
103
103
return count ;
@@ -137,7 +137,7 @@ static void show_list(const char *debug, int counted, int nr,
137
137
for (p = list ; p ; p = p -> next ) {
138
138
struct commit_list * pp ;
139
139
struct commit * commit = p -> item ;
140
- unsigned flags = commit -> object .flags ;
140
+ unsigned commit_flags = commit -> object .flags ;
141
141
enum object_type type ;
142
142
unsigned long size ;
143
143
char * buf = read_object_file (& commit -> object .oid , & type ,
@@ -146,9 +146,9 @@ static void show_list(const char *debug, int counted, int nr,
146
146
int subject_len ;
147
147
148
148
fprintf (stderr , "%c%c%c " ,
149
- (flags & TREESAME ) ? ' ' : 'T' ,
150
- (flags & UNINTERESTING ) ? 'U' : ' ' ,
151
- (flags & COUNTED ) ? 'C' : ' ' );
149
+ (commit_flags & TREESAME ) ? ' ' : 'T' ,
150
+ (commit_flags & UNINTERESTING ) ? 'U' : ' ' ,
151
+ (commit_flags & COUNTED ) ? 'C' : ' ' );
152
152
if (* commit_weight_at (& commit_weight , p -> item ))
153
153
fprintf (stderr , "%3d" , weight (p ));
154
154
else
@@ -173,9 +173,9 @@ static struct commit_list *best_bisection(struct commit_list *list, int nr)
173
173
best = list ;
174
174
for (p = list ; p ; p = p -> next ) {
175
175
int distance ;
176
- unsigned flags = p -> item -> object .flags ;
176
+ unsigned commit_flags = p -> item -> object .flags ;
177
177
178
- if (flags & TREESAME )
178
+ if (commit_flags & TREESAME )
179
179
continue ;
180
180
distance = weight (p );
181
181
if (nr - distance < distance )
@@ -214,9 +214,9 @@ static struct commit_list *best_bisection_sorted(struct commit_list *list, int n
214
214
215
215
for (p = list , cnt = 0 ; p ; p = p -> next ) {
216
216
int distance ;
217
- unsigned flags = p -> item -> object .flags ;
217
+ unsigned commit_flags = p -> item -> object .flags ;
218
218
219
- if (flags & TREESAME )
219
+ if (commit_flags & TREESAME )
220
220
continue ;
221
221
distance = weight (p );
222
222
if (nr - distance < distance )
@@ -261,7 +261,7 @@ static struct commit_list *best_bisection_sorted(struct commit_list *list, int n
261
261
*/
262
262
static struct commit_list * do_find_bisection (struct commit_list * list ,
263
263
int nr , int * weights ,
264
- int find_all , int first_parent_only )
264
+ unsigned bisect_flags )
265
265
{
266
266
int n , counted ;
267
267
struct commit_list * p ;
@@ -270,12 +270,12 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
270
270
271
271
for (n = 0 , p = list ; p ; p = p -> next ) {
272
272
struct commit * commit = p -> item ;
273
- unsigned flags = commit -> object .flags ;
273
+ unsigned commit_flags = commit -> object .flags ;
274
274
275
275
* commit_weight_at (& commit_weight , p -> item ) = & weights [n ++ ];
276
- switch (count_interesting_parents (commit , first_parent_only )) {
276
+ switch (count_interesting_parents (commit , bisect_flags )) {
277
277
case 0 :
278
- if (!(flags & TREESAME )) {
278
+ if (!(commit_flags & TREESAME )) {
279
279
weight_set (p , 1 );
280
280
counted ++ ;
281
281
show_list ("bisection 2 count one" ,
@@ -316,13 +316,13 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
316
316
continue ;
317
317
if (weight (p ) != -2 )
318
318
continue ;
319
- if (first_parent_only )
319
+ if (bisect_flags & FIND_BISECTION_FIRST_PARENT_ONLY )
320
320
BUG ("shouldn't be calling count-distance in fp mode" );
321
321
weight_set (p , count_distance (p ));
322
322
clear_distance (list );
323
323
324
324
/* Does it happen to be at exactly half-way? */
325
- if (!find_all && halfway (p , nr ))
325
+ if (!( bisect_flags & FIND_BISECTION_ALL ) && halfway (p , nr ))
326
326
return p ;
327
327
counted ++ ;
328
328
}
@@ -332,14 +332,14 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
332
332
while (counted < nr ) {
333
333
for (p = list ; p ; p = p -> next ) {
334
334
struct commit_list * q ;
335
- unsigned flags = p -> item -> object .flags ;
335
+ unsigned commit_flags = p -> item -> object .flags ;
336
336
337
337
if (0 <= weight (p ))
338
338
continue ;
339
339
340
340
for (q = p -> item -> parents ;
341
341
q ;
342
- q = first_parent_only ? NULL : q -> next ) {
342
+ q = bisect_flags & FIND_BISECTION_FIRST_PARENT_ONLY ? NULL : q -> next ) {
343
343
if (q -> item -> object .flags & UNINTERESTING )
344
344
continue ;
345
345
if (0 <= weight (q ))
@@ -353,7 +353,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
353
353
* add one for p itself if p is to be counted,
354
354
* otherwise inherit it from q directly.
355
355
*/
356
- if (!(flags & TREESAME )) {
356
+ if (!(commit_flags & TREESAME )) {
357
357
weight_set (p , weight (q )+ 1 );
358
358
counted ++ ;
359
359
show_list ("bisection 2 count one" ,
@@ -363,21 +363,21 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
363
363
weight_set (p , weight (q ));
364
364
365
365
/* Does it happen to be at exactly half-way? */
366
- if (!find_all && halfway (p , nr ))
366
+ if (!( bisect_flags & FIND_BISECTION_ALL ) && halfway (p , nr ))
367
367
return p ;
368
368
}
369
369
}
370
370
371
371
show_list ("bisection 2 counted all" , counted , nr , list );
372
372
373
- if (!find_all )
373
+ if (!( bisect_flags & FIND_BISECTION_ALL ) )
374
374
return best_bisection (list , nr );
375
375
else
376
376
return best_bisection_sorted (list , nr );
377
377
}
378
378
379
379
void find_bisection (struct commit_list * * commit_list , int * reaches ,
380
- int * all , int find_all , int first_parent_only )
380
+ int * all , unsigned bisect_flags )
381
381
{
382
382
int nr , on_list ;
383
383
struct commit_list * list , * p , * best , * next , * last ;
@@ -393,16 +393,16 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
393
393
for (nr = on_list = 0 , last = NULL , p = * commit_list ;
394
394
p ;
395
395
p = next ) {
396
- unsigned flags = p -> item -> object .flags ;
396
+ unsigned commit_flags = p -> item -> object .flags ;
397
397
398
398
next = p -> next ;
399
- if (flags & UNINTERESTING ) {
399
+ if (commit_flags & UNINTERESTING ) {
400
400
free (p );
401
401
continue ;
402
402
}
403
403
p -> next = last ;
404
404
last = p ;
405
- if (!(flags & TREESAME ))
405
+ if (!(commit_flags & TREESAME ))
406
406
nr ++ ;
407
407
on_list ++ ;
408
408
}
@@ -413,9 +413,9 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
413
413
weights = xcalloc (on_list , sizeof (* weights ));
414
414
415
415
/* Do the real work of finding bisection commit. */
416
- best = do_find_bisection (list , nr , weights , find_all , first_parent_only );
416
+ best = do_find_bisection (list , nr , weights , bisect_flags );
417
417
if (best ) {
418
- if (!find_all ) {
418
+ if (!( bisect_flags & FIND_BISECTION_ALL ) ) {
419
419
list -> item = best -> item ;
420
420
free_commit_list (list -> next );
421
421
best = list ;
@@ -1000,23 +1000,30 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
1000
1000
struct object_id * bisect_rev ;
1001
1001
char * steps_msg ;
1002
1002
int no_checkout = ref_exists ("BISECT_HEAD" );
1003
- int first_parent_only = file_exists ( git_path_bisect_first_parent ()) ;
1003
+ unsigned bisect_flags = 0 ;
1004
1004
1005
1005
read_bisect_terms (& term_bad , & term_good );
1006
1006
if (read_bisect_refs ())
1007
1007
die (_ ("reading bisect refs failed" ));
1008
1008
1009
+ if (file_exists (git_path_bisect_first_parent ()))
1010
+ bisect_flags |= FIND_BISECTION_FIRST_PARENT_ONLY ;
1011
+
1012
+ if (skipped_revs .nr )
1013
+ bisect_flags |= FIND_BISECTION_ALL ;
1014
+
1009
1015
res = check_good_are_ancestors_of_bad (r , prefix , no_checkout );
1010
1016
if (res )
1011
1017
return res ;
1012
1018
1013
1019
bisect_rev_setup (r , & revs , prefix , "%s" , "^%s" , 1 );
1014
- revs .first_parent_only = first_parent_only ;
1020
+
1021
+ revs .first_parent_only = !!(bisect_flags & FIND_BISECTION_FIRST_PARENT_ONLY );
1015
1022
revs .limited = 1 ;
1016
1023
1017
1024
bisect_common (& revs );
1018
1025
1019
- find_bisection (& revs .commits , & reaches , & all , !! skipped_revs . nr , first_parent_only );
1026
+ find_bisection (& revs .commits , & reaches , & all , bisect_flags );
1020
1027
revs .commits = managed_skipped (revs .commits , & tried );
1021
1028
1022
1029
if (!revs .commits ) {
0 commit comments