@@ -226,10 +226,11 @@ static struct commit_list *best_bisection_sorted(struct commit_list *list, int n
226
226
add_name_decoration (DECORATION_NONE , buf .buf , obj );
227
227
228
228
p -> item = array [i ].commit ;
229
- p = p -> next ;
229
+ if (i < cnt - 1 )
230
+ p = p -> next ;
230
231
}
231
- if ( p )
232
- p -> next = NULL ;
232
+ free_commit_list ( p -> next );
233
+ p -> next = NULL ;
233
234
strbuf_release (& buf );
234
235
free (array );
235
236
return list ;
@@ -360,28 +361,29 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
360
361
return best_bisection_sorted (list , nr );
361
362
}
362
363
363
- struct commit_list * find_bisection (struct commit_list * list ,
364
- int * reaches , int * all ,
365
- int find_all )
364
+ void find_bisection (struct commit_list * * commit_list , int * reaches ,
365
+ int * all , int find_all )
366
366
{
367
367
int nr , on_list ;
368
- struct commit_list * p , * best , * next , * last ;
368
+ struct commit_list * list , * p , * best , * next , * last ;
369
369
int * weights ;
370
370
371
- show_list ("bisection 2 entry" , 0 , 0 , list );
371
+ show_list ("bisection 2 entry" , 0 , 0 , * commit_list );
372
372
373
373
/*
374
374
* Count the number of total and tree-changing items on the
375
375
* list, while reversing the list.
376
376
*/
377
- for (nr = on_list = 0 , last = NULL , p = list ;
377
+ for (nr = on_list = 0 , last = NULL , p = * commit_list ;
378
378
p ;
379
379
p = next ) {
380
380
unsigned flags = p -> item -> object .flags ;
381
381
382
382
next = p -> next ;
383
- if (flags & UNINTERESTING )
383
+ if (flags & UNINTERESTING ) {
384
+ free (p );
384
385
continue ;
386
+ }
385
387
p -> next = last ;
386
388
last = p ;
387
389
if (!(flags & TREESAME ))
@@ -397,12 +399,16 @@ struct commit_list *find_bisection(struct commit_list *list,
397
399
/* Do the real work of finding bisection commit. */
398
400
best = do_find_bisection (list , nr , weights , find_all );
399
401
if (best ) {
400
- if (!find_all )
402
+ if (!find_all ) {
403
+ list -> item = best -> item ;
404
+ free_commit_list (list -> next );
405
+ best = list ;
401
406
best -> next = NULL ;
407
+ }
402
408
* reaches = weight (best );
403
409
}
404
410
free (weights );
405
- return best ;
411
+ * commit_list = best ;
406
412
}
407
413
408
414
static int register_ref (const char * refname , const struct object_id * oid ,
@@ -954,8 +960,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
954
960
955
961
bisect_common (& revs );
956
962
957
- revs .commits = find_bisection (revs .commits , & reaches , & all ,
958
- !!skipped_revs .nr );
963
+ find_bisection (& revs .commits , & reaches , & all , !!skipped_revs .nr );
959
964
revs .commits = managed_skipped (revs .commits , & tried );
960
965
961
966
if (!revs .commits ) {
0 commit comments