aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2020-12-16 22:27:59 +0000
committerJunio C Hamano <gitster@pobox.com>2020-12-16 21:56:39 -0800
commitb0ca120554be8d8f7faf98aa3b991441de76f5cf (patch)
tree2b77aee65ec174e812abc04053d38486c30a7f0e
parentc5a6f65527aa3b6f5d7cf25437a88d8727ab0646 (diff)
downloadgit-b0ca120554be8d8f7faf98aa3b991441de76f5cf.tar.gz
commit: move reverse_commit_list() from merge-recursive
Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--commit.c11
-rw-r--r--commit.h3
-rw-r--r--merge-recursive.c11
3 files changed, 14 insertions, 11 deletions
diff --git a/commit.c b/commit.c
index f53429c0ac..dc08a47b07 100644
--- a/commit.c
+++ b/commit.c
@@ -563,6 +563,17 @@ struct commit_list *copy_commit_list(struct commit_list *list)
return head;
}
+struct commit_list *reverse_commit_list(struct commit_list *list)
+{
+ struct commit_list *next = NULL, *current, *backup;
+ for (current = list; current; current = backup) {
+ backup = current->next;
+ current->next = next;
+ next = current;
+ }
+ return next;
+}
+
void free_commit_list(struct commit_list *list)
{
while (list)
diff --git a/commit.h b/commit.h
index 5467786c7b..3e9139a000 100644
--- a/commit.h
+++ b/commit.h
@@ -177,6 +177,9 @@ void commit_list_sort_by_date(struct commit_list **list);
/* Shallow copy of the input list */
struct commit_list *copy_commit_list(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);
struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
diff --git a/merge-recursive.c b/merge-recursive.c
index f736a0f632..b052974f19 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -3517,17 +3517,6 @@ static int merge_trees_internal(struct merge_options *opt,
return clean;
}
-static struct commit_list *reverse_commit_list(struct commit_list *list)
-{
- struct commit_list *next = NULL, *current, *backup;
- for (current = list; current; current = backup) {
- backup = current->next;
- current->next = next;
- next = current;
- }
- return next;
-}
-
/*
* Merge the commits h1 and h2, returning a flag (int) indicating the
* cleanness of the merge. Also, if opt->priv->call_depth, create a