From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Subject: [PATCH 1/3] commit: rename `copy_commit_list()` to conform to coding guidelines
Date: Thu, 15 Jan 2026 10:35:32 +0100 [thread overview]
Message-ID: <20260115-pks-commit-list-coding-guidelines-v1-1-c58868dbf412@pks.im> (raw)
In-Reply-To: <20260115-pks-commit-list-coding-guidelines-v1-0-c58868dbf412@pks.im>
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>
---
builtin/commit.c | 2 +-
commit.c | 2 +-
commit.h | 11 ++++++++++-
merge-ort.c | 2 +-
revision.c | 4 ++--
sequencer.c | 2 +-
6 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index 0243f17d53..0aa3690b04 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -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;
diff --git a/commit.c b/commit.c
index efd0c02683..c5c66d3a6b 100644
--- 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;
diff --git a/commit.h b/commit.h
index 79a761c37d..2faf08cd18 100644
--- 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,
diff --git a/merge-ort.c b/merge-ort.c
index 2b837a58c3..f31754c361 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -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;
diff --git a/revision.c b/revision.c
index 1858e093ee..9f5baceb85 100644
--- a/revision.c
+++ b/revision.c
@@ -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)
diff --git a/sequencer.c b/sequencer.c
index 71ed31c774..f38d247b10 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -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))) {
--
2.52.0.660.gd05f3a8ea5.dirty
next prev parent reply other threads:[~2026-01-15 9:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 9:35 [PATCH 0/3] Rename commit list functions to conform to coding guidelines Patrick Steinhardt
2026-01-15 9:35 ` Patrick Steinhardt [this message]
2026-01-15 9:35 ` [PATCH 2/3] commit: rename `reverse_commit_list()` " Patrick Steinhardt
2026-01-15 9:35 ` [PATCH 3/3] commit: rename `free_commit_list()` " Patrick Steinhardt
2026-01-15 13:32 ` [PATCH 0/3] Rename commit list functions " Junio C Hamano
2026-01-16 6:54 ` Patrick Steinhardt
2026-01-16 16:48 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260115-pks-commit-list-coding-guidelines-v1-1-c58868dbf412@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox