Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 89b5f1d

Browse files
René Scharfegitster
authored andcommitted
sequencer: export commit_list_append()
This function can be used in other parts of git. Give it a new home in commit.c. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ba8e632 commit 89b5f1d

File tree

3 files changed

+29
-27
lines changed

3 files changed

+29
-27
lines changed

commit.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,3 +1214,30 @@ struct commit *get_merge_parent(const char *name)
12141214
}
12151215
return commit;
12161216
}
1217+
1218+
/*
1219+
* Append a commit to the end of the commit_list.
1220+
*
1221+
* next starts by pointing to the variable that holds the head of an
1222+
* empty commit_list, and is updated to point to the "next" field of
1223+
* the last item on the list as new commits are appended.
1224+
*
1225+
* Usage example:
1226+
*
1227+
* struct commit_list *list;
1228+
* struct commit_list **next = &list;
1229+
*
1230+
* next = commit_list_append(c1, next);
1231+
* next = commit_list_append(c2, next);
1232+
* assert(commit_list_count(list) == 2);
1233+
* return list;
1234+
*/
1235+
struct commit_list **commit_list_append(struct commit *commit,
1236+
struct commit_list **next)
1237+
{
1238+
struct commit_list *new = xmalloc(sizeof(struct commit_list));
1239+
new->item = commit;
1240+
*next = new;
1241+
new->next = NULL;
1242+
return &new->next;
1243+
}

commit.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ int find_commit_subject(const char *commit_buffer, const char **subject);
5353

5454
struct commit_list *commit_list_insert(struct commit *item,
5555
struct commit_list **list);
56+
struct commit_list **commit_list_append(struct commit *commit,
57+
struct commit_list **next);
5658
unsigned commit_list_count(const struct commit_list *l);
5759
struct commit_list *commit_list_insert_by_date(struct commit *item,
5860
struct commit_list **list);

sequencer.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -468,33 +468,6 @@ static void read_and_refresh_cache(struct replay_opts *opts)
468468
rollback_lock_file(&index_lock);
469469
}
470470

471-
/*
472-
* Append a commit to the end of the commit_list.
473-
*
474-
* next starts by pointing to the variable that holds the head of an
475-
* empty commit_list, and is updated to point to the "next" field of
476-
* the last item on the list as new commits are appended.
477-
*
478-
* Usage example:
479-
*
480-
* struct commit_list *list;
481-
* struct commit_list **next = &list;
482-
*
483-
* next = commit_list_append(c1, next);
484-
* next = commit_list_append(c2, next);
485-
* assert(commit_list_count(list) == 2);
486-
* return list;
487-
*/
488-
static struct commit_list **commit_list_append(struct commit *commit,
489-
struct commit_list **next)
490-
{
491-
struct commit_list *new = xmalloc(sizeof(struct commit_list));
492-
new->item = commit;
493-
*next = new;
494-
new->next = NULL;
495-
return &new->next;
496-
}
497-
498471
static int format_todo(struct strbuf *buf, struct commit_list *todo_list,
499472
struct replay_opts *opts)
500473
{

0 commit comments

Comments
 (0)