]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit: rename `reverse_commit_list()` to conform to coding guidelines
authorPatrick Steinhardt <ps@pks.im>
Thu, 15 Jan 2026 09:35:33 +0000 (10:35 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 15 Jan 2026 13:32:31 +0000 (05:32 -0800)
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>
builtin/merge-tree.c
builtin/stash.c
commit.c
commit.h
merge-ort.c
sequencer.c

index 1c063d9a41a695a2abfc60aa99af2b327e786195..979a55d3b2983fb0810633fe855466c77b487ad0 100644 (file)
@@ -483,7 +483,7 @@ static int real_merge(struct merge_tree_options *o,
                        exit(128);
                if (!merge_bases && !o->allow_unrelated_histories)
                        die(_("refusing to merge unrelated histories"));
-               merge_bases = reverse_commit_list(merge_bases);
+               merge_bases = commit_list_reverse(merge_bases);
                merge_incore_recursive(&opt, merge_bases, parent1, parent2, &result);
                free_commit_list(merge_bases);
        }
index 948eba06fbccb3060d116db5862816ddc5d1485d..4cb2351787c33dcb1fe5eef6a2b82d6c441a49e2 100644 (file)
@@ -2308,7 +2308,7 @@ static int do_export_stash(struct repository *r,
         * but where their first parents form a chain to our original empty
         * base commit.
         */
-       items = reverse_commit_list(items);
+       items = commit_list_reverse(items);
        for (cur = items; cur; cur = cur->next) {
                struct commit_list *parents = NULL;
                struct commit_list **next = &parents;
index c5c66d3a6b2b78d3e1130a86713ddfbbca9bb7a8..36f02c96aabb9d4217f732bd8918d3591505a972 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -691,7 +691,7 @@ struct commit_list *commit_list_copy(const struct commit_list *list)
        return head;
 }
 
-struct commit_list *reverse_commit_list(struct commit_list *list)
+struct commit_list *commit_list_reverse(struct commit_list *list)
 {
        struct commit_list *next = NULL, *current, *backup;
        for (current = list; current; current = backup) {
index 2faf08cd1863d5bb33b9112f075bcdbddcae9413..f50d9e5a4abe918ddcd090dae286f9ac9f49f726 100644 (file)
--- a/commit.h
+++ b/commit.h
@@ -189,7 +189,7 @@ void commit_list_sort_by_date(struct commit_list **list);
 struct commit_list *commit_list_copy(const struct commit_list *list);
 
 /* Modify list in-place to reverse it, returning new head; list will be tail */
-struct commit_list *reverse_commit_list(struct commit_list *list);
+struct commit_list *commit_list_reverse(struct commit_list *list);
 
 void free_commit_list(struct commit_list *list);
 
@@ -202,6 +202,11 @@ static inline struct commit_list *copy_commit_list(struct commit_list *l)
        return commit_list_copy(l);
 }
 
+static inline struct commit_list *reverse_commit_list(struct commit_list *l)
+{
+       return commit_list_reverse(l);
+}
+
 struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
 
 const char *repo_logmsg_reencode(struct repository *r,
index f31754c3611c43cc306383ffb81febcc88bf81c3..2ddaaffc263d465d83b7ebfaa343cd5863587f8b 100644 (file)
@@ -5314,7 +5314,7 @@ static void merge_ort_internal(struct merge_options *opt,
                        goto out;
                }
                /* See merge-ort.h:merge_incore_recursive() declaration NOTE */
-               merge_bases = reverse_commit_list(merge_bases);
+               merge_bases = commit_list_reverse(merge_bases);
        }
 
        merged_merge_bases = pop_commit(&merge_bases);
index f38d247b1099d180dafd9fc3e8a0cda26249de3f..e09f8eed5514258a6c7bbbbc91f41796340e8f5b 100644 (file)
@@ -4317,7 +4317,7 @@ static int do_merge(struct repository *r,
                      git_path_merge_head(r), 0);
        write_message("no-ff", 5, git_path_merge_mode(r), 0);
 
-       bases = reverse_commit_list(bases);
+       bases = commit_list_reverse(bases);
 
        repo_read_index(r);
        init_ui_merge_options(&o, r);