@@ -88,15 +88,16 @@ static inline void weight_set(struct commit_list *elem, int weight)
88
88
* * commit_weight_at (& commit_weight , elem -> item ) = weight ;
89
89
}
90
90
91
- static int count_interesting_parents (struct commit * commit )
91
+ static int count_interesting_parents (struct commit * commit , int first_parent_only )
92
92
{
93
93
struct commit_list * p ;
94
94
int count ;
95
95
96
96
for (count = 0 , p = commit -> parents ; p ; p = p -> next ) {
97
- if (p -> item -> object .flags & UNINTERESTING )
98
- continue ;
99
- count ++ ;
97
+ if (!(p -> item -> object .flags & UNINTERESTING ))
98
+ count ++ ;
99
+ if (first_parent_only )
100
+ break ;
100
101
}
101
102
return count ;
102
103
}
@@ -259,7 +260,7 @@ static struct commit_list *best_bisection_sorted(struct commit_list *list, int n
259
260
*/
260
261
static struct commit_list * do_find_bisection (struct commit_list * list ,
261
262
int nr , int * weights ,
262
- int find_all )
263
+ int find_all , int first_parent_only )
263
264
{
264
265
int n , counted ;
265
266
struct commit_list * p ;
@@ -271,7 +272,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
271
272
unsigned flags = commit -> object .flags ;
272
273
273
274
* commit_weight_at (& commit_weight , p -> item ) = & weights [n ++ ];
274
- switch (count_interesting_parents (commit )) {
275
+ switch (count_interesting_parents (commit , first_parent_only )) {
275
276
case 0 :
276
277
if (!(flags & TREESAME )) {
277
278
weight_set (p , 1 );
@@ -314,6 +315,8 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
314
315
continue ;
315
316
if (weight (p ) != -2 )
316
317
continue ;
318
+ if (first_parent_only )
319
+ BUG ("shouldn't be calling count-distance in fp mode" );
317
320
weight_set (p , count_distance (p ));
318
321
clear_distance (list );
319
322
@@ -332,7 +335,10 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
332
335
333
336
if (0 <= weight (p ))
334
337
continue ;
335
- for (q = p -> item -> parents ; q ; q = q -> next ) {
338
+
339
+ for (q = p -> item -> parents ;
340
+ q ;
341
+ q = first_parent_only ? NULL : q -> next ) {
336
342
if (q -> item -> object .flags & UNINTERESTING )
337
343
continue ;
338
344
if (0 <= weight (q ))
@@ -370,7 +376,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
370
376
}
371
377
372
378
void find_bisection (struct commit_list * * commit_list , int * reaches ,
373
- int * all , int find_all )
379
+ int * all , int find_all , int first_parent_only )
374
380
{
375
381
int nr , on_list ;
376
382
struct commit_list * list , * p , * best , * next , * last ;
@@ -406,7 +412,7 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
406
412
weights = xcalloc (on_list , sizeof (* weights ));
407
413
408
414
/* Do the real work of finding bisection commit. */
409
- best = do_find_bisection (list , nr , weights , find_all );
415
+ best = do_find_bisection (list , nr , weights , find_all , first_parent_only );
410
416
if (best ) {
411
417
if (!find_all ) {
412
418
list -> item = best -> item ;
@@ -991,6 +997,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix, int
991
997
enum bisect_error res = BISECT_OK ;
992
998
struct object_id * bisect_rev ;
993
999
char * steps_msg ;
1000
+ int first_parent_only = 0 ; /* TODO: pass --first-parent flag from git bisect start */
994
1001
995
1002
read_bisect_terms (& term_bad , & term_good );
996
1003
if (read_bisect_refs ())
@@ -1001,11 +1008,12 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix, int
1001
1008
return res ;
1002
1009
1003
1010
bisect_rev_setup (r , & revs , prefix , "%s" , "^%s" , 1 );
1011
+ revs .first_parent_only = first_parent_only ;
1004
1012
revs .limited = 1 ;
1005
1013
1006
1014
bisect_common (& revs );
1007
1015
1008
- find_bisection (& revs .commits , & reaches , & all , !!skipped_revs .nr );
1016
+ find_bisection (& revs .commits , & reaches , & all , !!skipped_revs .nr , first_parent_only );
1009
1017
revs .commits = managed_skipped (revs .commits , & tried );
1010
1018
1011
1019
if (!revs .commits ) {
0 commit comments