@@ -409,74 +409,89 @@ static int remove_redundant(struct repository *r, struct commit **array, int cnt
409
409
return remove_redundant_no_gen (r , array , cnt );
410
410
}
411
411
412
- static struct commit_list * get_merge_bases_many_0 (struct repository * r ,
413
- struct commit * one ,
414
- int n ,
415
- struct commit * * twos ,
416
- int cleanup )
412
+ static int get_merge_bases_many_0 (struct repository * r ,
413
+ struct commit * one ,
414
+ int n ,
415
+ struct commit * * twos ,
416
+ int cleanup ,
417
+ struct commit_list * * result )
417
418
{
418
419
struct commit_list * list ;
419
420
struct commit * * rslt ;
420
- struct commit_list * result = NULL ;
421
421
int cnt , i ;
422
422
423
- if (merge_bases_many (r , one , n , twos , & result ) < 0 )
424
- return NULL ;
423
+ if (merge_bases_many (r , one , n , twos , result ) < 0 )
424
+ return -1 ;
425
425
for (i = 0 ; i < n ; i ++ ) {
426
426
if (one == twos [i ])
427
- return result ;
427
+ return 0 ;
428
428
}
429
- if (!result || !result -> next ) {
429
+ if (!* result || !( * result ) -> next ) {
430
430
if (cleanup ) {
431
431
clear_commit_marks (one , all_flags );
432
432
clear_commit_marks_many (n , twos , all_flags );
433
433
}
434
- return result ;
434
+ return 0 ;
435
435
}
436
436
437
437
/* There are more than one */
438
- cnt = commit_list_count (result );
438
+ cnt = commit_list_count (* result );
439
439
CALLOC_ARRAY (rslt , cnt );
440
- for (list = result , i = 0 ; list ; list = list -> next )
440
+ for (list = * result , i = 0 ; list ; list = list -> next )
441
441
rslt [i ++ ] = list -> item ;
442
- free_commit_list (result );
442
+ free_commit_list (* result );
443
+ * result = NULL ;
443
444
444
445
clear_commit_marks (one , all_flags );
445
446
clear_commit_marks_many (n , twos , all_flags );
446
447
447
448
cnt = remove_redundant (r , rslt , cnt );
448
449
if (cnt < 0 ) {
449
450
free (rslt );
450
- return NULL ;
451
+ return -1 ;
451
452
}
452
- result = NULL ;
453
453
for (i = 0 ; i < cnt ; i ++ )
454
- commit_list_insert_by_date (rslt [i ], & result );
454
+ commit_list_insert_by_date (rslt [i ], result );
455
455
free (rslt );
456
- return result ;
456
+ return 0 ;
457
457
}
458
458
459
459
struct commit_list * repo_get_merge_bases_many (struct repository * r ,
460
460
struct commit * one ,
461
461
int n ,
462
462
struct commit * * twos )
463
463
{
464
- return get_merge_bases_many_0 (r , one , n , twos , 1 );
464
+ struct commit_list * result = NULL ;
465
+ if (get_merge_bases_many_0 (r , one , n , twos , 1 , & result ) < 0 ) {
466
+ free_commit_list (result );
467
+ return NULL ;
468
+ }
469
+ return result ;
465
470
}
466
471
467
472
struct commit_list * repo_get_merge_bases_many_dirty (struct repository * r ,
468
473
struct commit * one ,
469
474
int n ,
470
475
struct commit * * twos )
471
476
{
472
- return get_merge_bases_many_0 (r , one , n , twos , 0 );
477
+ struct commit_list * result = NULL ;
478
+ if (get_merge_bases_many_0 (r , one , n , twos , 0 , & result ) < 0 ) {
479
+ free_commit_list (result );
480
+ return NULL ;
481
+ }
482
+ return result ;
473
483
}
474
484
475
485
struct commit_list * repo_get_merge_bases (struct repository * r ,
476
486
struct commit * one ,
477
487
struct commit * two )
478
488
{
479
- return get_merge_bases_many_0 (r , one , 1 , & two , 1 );
489
+ struct commit_list * result = NULL ;
490
+ if (get_merge_bases_many_0 (r , one , 1 , & two , 1 , & result ) < 0 ) {
491
+ free_commit_list (result );
492
+ return NULL ;
493
+ }
494
+ return result ;
480
495
}
481
496
482
497
/*
0 commit comments