]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit: rename `copy_commit_list()` to conform to coding guidelines
authorPatrick Steinhardt <ps@pks.im>
Thu, 15 Jan 2026 09:35:32 +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, `copy_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/commit.c
commit.c
commit.h
merge-ort.c
revision.c
sequencer.c

index 0243f17d53c97c62432ce77249966d4ef4ed7100..0aa3690b04b9554fecc0762c2dfdeaa578114210 100644 (file)
@@ -1849,7 +1849,7 @@ int cmd_commit(int argc,
        } else if (amend) {
                if (!reflog_msg)
                        reflog_msg = "commit (amend)";
-               parents = copy_commit_list(current_head->parents);
+               parents = commit_list_copy(current_head->parents);
        } else if (whence == FROM_MERGE) {
                struct strbuf m = STRBUF_INIT;
                FILE *fp;
index efd0c026831e6b41ea428151ed7a1a6a3c8223e3..c5c66d3a6b2b78d3e1130a86713ddfbbca9bb7a8 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -680,7 +680,7 @@ unsigned commit_list_count(const struct commit_list *l)
        return c;
 }
 
-struct commit_list *copy_commit_list(const struct commit_list *list)
+struct commit_list *commit_list_copy(const struct commit_list *list)
 {
        struct commit_list *head = NULL;
        struct commit_list **pp = &head;
index 79a761c37df0236b386b18a69e874793de3f1c3c..2faf08cd1863d5bb33b9112f075bcdbddcae9413 100644 (file)
--- a/commit.h
+++ b/commit.h
@@ -186,13 +186,22 @@ struct commit_list *commit_list_insert_by_date(struct commit *item,
 void commit_list_sort_by_date(struct commit_list **list);
 
 /* Shallow copy of the input list */
-struct commit_list *copy_commit_list(const 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);
 
 void free_commit_list(struct commit_list *list);
 
+/*
+ * Deprecated compatibility functions for `struct commit_list`, to be removed
+ * once Git 2.53 is released.
+ */
+static inline struct commit_list *copy_commit_list(struct commit_list *l)
+{
+       return commit_list_copy(l);
+}
+
 struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
 
 const char *repo_logmsg_reencode(struct repository *r,
index 2b837a58c3a6f8c3c604e99623c360f9ba70bbec..f31754c3611c43cc306383ffb81febcc88bf81c3 100644 (file)
@@ -5301,7 +5301,7 @@ static void merge_ort_internal(struct merge_options *opt,
                               struct commit *h2,
                               struct merge_result *result)
 {
-       struct commit_list *merge_bases = copy_commit_list(_merge_bases);
+       struct commit_list *merge_bases = commit_list_copy(_merge_bases);
        struct commit *next;
        struct commit *merged_merge_bases;
        const char *ancestor_name;
index 1858e093eeeb89e0cad0422c9bda909d5b96593f..9f5baceb85f2b33721a8cb81f10b76b350d64867 100644 (file)
@@ -4224,7 +4224,7 @@ static void save_parents(struct rev_info *revs, struct commit *commit)
        if (*pp)
                return;
        if (commit->parents)
-               *pp = copy_commit_list(commit->parents);
+               *pp = commit_list_copy(commit->parents);
        else
                *pp = EMPTY_PARENT_LIST;
 }
@@ -4294,7 +4294,7 @@ static void track_linear(struct rev_info *revs, struct commit *commit)
                        commit->object.flags |= TRACK_LINEAR;
        }
        free_commit_list(revs->previous_parents);
-       revs->previous_parents = copy_commit_list(commit->parents);
+       revs->previous_parents = commit_list_copy(commit->parents);
 }
 
 static struct commit *get_revision_1(struct rev_info *revs)
index 71ed31c774068862104efe5faaa1eb02870861e6..f38d247b1099d180dafd9fc3e8a0cda26249de3f 100644 (file)
@@ -1566,7 +1566,7 @@ static int try_to_commit(struct repository *r,
                        res = error(_("unable to parse commit author"));
                        goto out;
                }
-               parents = copy_commit_list(current_head->parents);
+               parents = commit_list_copy(current_head->parents);
                extra = read_commit_extra_headers(current_head, exclude_gpgsig);
        } else if (current_head &&
                   (!(flags & CREATE_ROOT_COMMIT) || (flags & AMEND_MSG))) {