Browse Source

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>
maint
Elijah Newren 4 years ago committed by Junio C Hamano
parent
commit
b0ca120554
  1. 11
      commit.c
  2. 3
      commit.h
  3. 11
      merge-recursive.c

11
commit.c

@ -563,6 +563,17 @@ struct commit_list *copy_commit_list(struct commit_list *list)
return head; 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) void free_commit_list(struct commit_list *list)
{ {
while (list) while (list)

3
commit.h

@ -177,6 +177,9 @@ void commit_list_sort_by_date(struct commit_list **list);
/* Shallow copy of the input list */ /* Shallow copy of the input list */
struct commit_list *copy_commit_list(struct commit_list *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); void free_commit_list(struct commit_list *list);


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

11
merge-recursive.c

@ -3517,17 +3517,6 @@ static int merge_trees_internal(struct merge_options *opt,
return clean; 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 * Merge the commits h1 and h2, returning a flag (int) indicating the
* cleanness of the merge. Also, if opt->priv->call_depth, create a * cleanness of the merge. Also, if opt->priv->call_depth, create a

Loading…
Cancel
Save