Skip to content

Commit b0ca120

Browse files
newrengitster
authored andcommitted
commit: move reverse_commit_list() from merge-recursive
Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c5a6f65 commit b0ca120

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

commit.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,17 @@ struct commit_list *copy_commit_list(struct commit_list *list)
563563
return head;
564564
}
565565

566+
struct commit_list *reverse_commit_list(struct commit_list *list)
567+
{
568+
struct commit_list *next = NULL, *current, *backup;
569+
for (current = list; current; current = backup) {
570+
backup = current->next;
571+
current->next = next;
572+
next = current;
573+
}
574+
return next;
575+
}
576+
566577
void free_commit_list(struct commit_list *list)
567578
{
568579
while (list)

commit.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ void commit_list_sort_by_date(struct commit_list **list);
177177
/* Shallow copy of the input list */
178178
struct commit_list *copy_commit_list(struct commit_list *list);
179179

180+
/* Modify list in-place to reverse it, returning new head; list will be tail */
181+
struct commit_list *reverse_commit_list(struct commit_list *list);
182+
180183
void free_commit_list(struct commit_list *list);
181184

182185
struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */

merge-recursive.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3517,17 +3517,6 @@ static int merge_trees_internal(struct merge_options *opt,
35173517
return clean;
35183518
}
35193519

3520-
static struct commit_list *reverse_commit_list(struct commit_list *list)
3521-
{
3522-
struct commit_list *next = NULL, *current, *backup;
3523-
for (current = list; current; current = backup) {
3524-
backup = current->next;
3525-
current->next = next;
3526-
next = current;
3527-
}
3528-
return next;
3529-
}
3530-
35313520
/*
35323521
* Merge the commits h1 and h2, returning a flag (int) indicating the
35333522
* cleanness of the merge. Also, if opt->priv->call_depth, create a

0 commit comments

Comments
 (0)