public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Subject: [PATCH 2/3] commit: rename `reverse_commit_list()` to conform to coding guidelines
Date: Thu, 15 Jan 2026 10:35:33 +0100	[thread overview]
Message-ID: <20260115-pks-commit-list-coding-guidelines-v1-2-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, `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>
---
 builtin/merge-tree.c | 2 +-
 builtin/stash.c      | 2 +-
 commit.c             | 2 +-
 commit.h             | 7 ++++++-
 merge-ort.c          | 2 +-
 sequencer.c          | 2 +-
 6 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 1c063d9a41..979a55d3b2 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -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);
 	}
diff --git a/builtin/stash.c b/builtin/stash.c
index 948eba06fb..4cb2351787 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -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;
diff --git a/commit.c b/commit.c
index c5c66d3a6b..36f02c96aa 100644
--- 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) {
diff --git a/commit.h b/commit.h
index 2faf08cd18..f50d9e5a4a 100644
--- 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,
diff --git a/merge-ort.c b/merge-ort.c
index f31754c361..2ddaaffc26 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -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);
diff --git a/sequencer.c b/sequencer.c
index f38d247b10..e09f8eed55 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -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);

-- 
2.52.0.660.gd05f3a8ea5.dirty


  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 ` [PATCH 1/3] commit: rename `copy_commit_list()` " Patrick Steinhardt
2026-01-15  9:35 ` Patrick Steinhardt [this message]
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-2-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