@@ -60,6 +60,7 @@ static int paint_down_to_common(struct repository *r,
6060 struct prio_queue queue = { compare_commits_by_gen_then_commit_date };
6161 int i ;
6262 timestamp_t last_gen = GENERATION_NUMBER_INFINITY ;
63+ struct commit_list * * tail = result ;
6364
6465 if (!min_generation && !corrected_commit_dates_enabled (r ))
6566 queue .compare = compare_commits_by_commit_date ;
@@ -95,7 +96,7 @@ static int paint_down_to_common(struct repository *r,
9596 if (flags == (PARENT1 | PARENT2 )) {
9697 if (!(commit -> object .flags & RESULT )) {
9798 commit -> object .flags |= RESULT ;
98- commit_list_insert_by_date (commit , result );
99+ tail = commit_list_append (commit , tail );
99100 }
100101 /* Mark parents of a found merge stale */
101102 flags |= STALE ;
@@ -128,6 +129,7 @@ static int paint_down_to_common(struct repository *r,
128129 }
129130
130131 clear_prio_queue (& queue );
132+ commit_list_sort_by_date (result );
131133 return 0 ;
132134}
133135
@@ -136,7 +138,7 @@ static int merge_bases_many(struct repository *r,
136138 struct commit * * twos ,
137139 struct commit_list * * result )
138140{
139- struct commit_list * list = NULL ;
141+ struct commit_list * list = NULL , * * tail = result ;
140142 int i ;
141143
142144 for (i = 0 ; i < n ; i ++ ) {
@@ -171,8 +173,9 @@ static int merge_bases_many(struct repository *r,
171173 while (list ) {
172174 struct commit * commit = pop_commit (& list );
173175 if (!(commit -> object .flags & STALE ))
174- commit_list_insert_by_date (commit , result );
176+ tail = commit_list_append (commit , tail );
175177 }
178+ commit_list_sort_by_date (result );
176179 return 0 ;
177180}
178181
@@ -425,7 +428,7 @@ static int get_merge_bases_many_0(struct repository *r,
425428 int cleanup ,
426429 struct commit_list * * result )
427430{
428- struct commit_list * list ;
431+ struct commit_list * list , * * tail = result ;
429432 struct commit * * rslt ;
430433 size_t cnt , i ;
431434 int ret ;
@@ -461,7 +464,8 @@ static int get_merge_bases_many_0(struct repository *r,
461464 return -1 ;
462465 }
463466 for (i = 0 ; i < cnt ; i ++ )
464- commit_list_insert_by_date (rslt [i ], result );
467+ tail = commit_list_append (rslt [i ], tail );
468+ commit_list_sort_by_date (result );
465469 free (rslt );
466470 return 0 ;
467471}
0 commit comments