commit: rename `reverse_commit_list()` to conform to coding guidelines
Our coding guidelines say that: Functions that operate on `struct S` are named `S_<verb>()` and should generally receive a pointer to `struct S` as first parameter. While most of the functions related to `struct commit_list` already follow that naming schema, `reverse_commit_list()` doesn't. Rename the function to address this and adjust all of its callers. Add a compatibility wrapper for the old function name to ease the transition and avoid any semantic conflicts with in-flight patch series. This wrapper will be removed once Git 2.53 has been released. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Jan 15, 2026 at 10:35 UTC
a468f3cefab32eed7d9a12bd6b93719d38ec67a6
6 files changed
+11
-6
builtin/merge-tree.c
+1
-1
@@ -483,7 +483,7 @@ static int real_merge(struct merge_tree_options *o,
483
exit(128);
484
if (!merge_bases && !o->allow_unrelated_histories)
485
die(_("refusing to merge unrelated histories"));
486
- merge_bases = reverse_commit_list(merge_bases);
486
+ merge_bases = commit_list_reverse(merge_bases);
487
merge_incore_recursive(&opt, merge_bases, parent1, parent2, &result);
488
free_commit_list(merge_bases);
489
}
builtin/stash.c
+1
-1
@@ -2308,7 +2308,7 @@ static int do_export_stash(struct repository *r,
2308
* but where their first parents form a chain to our original empty
2309
* base commit.
2310
*/
2311
- items = reverse_commit_list(items);
2311
+ items = commit_list_reverse(items);
2312
for (cur = items; cur; cur = cur->next) {
2313
struct commit_list *parents = NULL;
2314
struct commit_list **next = &parents;
commit.c
+1
-1
@@ -691,7 +691,7 @@ struct commit_list *commit_list_copy(const struct commit_list *list)
691
return head;
692
}
693
694
-struct commit_list *reverse_commit_list(struct commit_list *list)
694
+struct commit_list *commit_list_reverse(struct commit_list *list)
695
{
696
struct commit_list *next = NULL, *current, *backup;
697
for (current = list; current; current = backup) {
commit.h
+6
-1
@@ -189,7 +189,7 @@ void commit_list_sort_by_date(struct commit_list **list);
189
struct commit_list *commit_list_copy(const struct commit_list *list);
190
191
/* Modify list in-place to reverse it, returning new head; list will be tail */
192
-struct commit_list *reverse_commit_list(struct commit_list *list);
192
+struct commit_list *commit_list_reverse(struct commit_list *list);
193
194
void free_commit_list(struct commit_list *list);
195
@@ -202,6 +202,11 @@ static inline struct commit_list *copy_commit_list(struct commit_list *l)
202
return commit_list_copy(l);
203
}
204
205
+static inline struct commit_list *reverse_commit_list(struct commit_list *l)
206
+{
207
+ return commit_list_reverse(l);
208
+}
209
+
210
struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
211
212
const char *repo_logmsg_reencode(struct repository *r,
merge-ort.c
+1
-1
@@ -5314,7 +5314,7 @@ static void merge_ort_internal(struct merge_options *opt,
5314
goto out;
5315
}
5316
/* See merge-ort.h:merge_incore_recursive() declaration NOTE */
5317
- merge_bases = reverse_commit_list(merge_bases);
5317
+ merge_bases = commit_list_reverse(merge_bases);
5318
}
5319
5320
merged_merge_bases = pop_commit(&merge_bases);
sequencer.c
+1
-1
@@ -4317,7 +4317,7 @@ static int do_merge(struct repository *r,
4317
git_path_merge_head(r), 0);
4318
write_message("no-ff", 5, git_path_merge_mode(r), 0);
4319
4320
- bases = reverse_commit_list(bases);
4320
+ bases = commit_list_reverse(bases);
4321
4322
repo_read_index(r);
4323
init_ui_merge_options(&o, r);