summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2012-04-25 20:35:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-04-25 21:51:17 (GMT)
commit89b5f1d9c5e64c9e232fa1ebe0ea407c8773b79a (patch)
treead44ef41a6a12db2bb60945fea81d514afed71fe /commit.c
parentba8e6326f16748d67fbeda65ffde4729760c64f0 (diff)
downloadgit-89b5f1d9c5e64c9e232fa1ebe0ea407c8773b79a.zip
git-89b5f1d9c5e64c9e232fa1ebe0ea407c8773b79a.tar.gz
git-89b5f1d9c5e64c9e232fa1ebe0ea407c8773b79a.tar.bz2
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 <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/commit.c b/commit.c
index b80a452..8361acb 100644
--- a/commit.c
+++ b/commit.c
@@ -1214,3 +1214,30 @@ struct commit *get_merge_parent(const char *name)
}
return commit;
}
+
+/*
+ * Append a commit to the end of the commit_list.
+ *
+ * next starts by pointing to the variable that holds the head of an
+ * empty commit_list, and is updated to point to the "next" field of
+ * the last item on the list as new commits are appended.
+ *
+ * Usage example:
+ *
+ * struct commit_list *list;
+ * struct commit_list **next = &list;
+ *
+ * next = commit_list_append(c1, next);
+ * next = commit_list_append(c2, next);
+ * assert(commit_list_count(list) == 2);
+ * return list;
+ */
+struct commit_list **commit_list_append(struct commit *commit,
+ struct commit_list **next)
+{
+ struct commit_list *new = xmalloc(sizeof(struct commit_list));
+ new->item = commit;
+ *next = new;
+ new->next = NULL;
+ return &new->next;
+}