]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit: move reverse_commit_list() from merge-recursive
authorElijah Newren <newren@gmail.com>
Wed, 16 Dec 2020 22:27:59 +0000 (22:27 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 17 Dec 2020 05:56:39 +0000 (21:56 -0800)
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit.c
commit.h
merge-recursive.c

index f53429c0ac34d933a06f6051cd6b5e519408e4be..dc08a47b073464c136753d260d70cfbac51a5dff 100644 (file)
--- 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)
index 5467786c7be332299e54a954eb9af55b64d58848..3e9139a00049adfa01bc9a2a38a3ec2b4fc5b1a0 100644 (file)
--- 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 */
index f736a0f63234fee610b42abdf2d7458d932e1d70..b052974f191cd82741475a019076c90e45d6d4de 100644 (file)
@@ -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