From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: git@vger.kernel.org
Cc: Jeff King <peff@peff.net>,
Michael Mueller <mmueller@vigilantsw.com>,
Ramkumar Ramachandra <artagnon@gmail.com>,
Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 1/3] sequencer: export commit_list_append()
Date: Wed, 25 Apr 2012 22:35:27 +0200 [thread overview]
Message-ID: <4F98600F.6000404@lsrfire.ath.cx> (raw)
In-Reply-To: <4F985D0A.9020100@lsrfire.ath.cx>
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>
---
commit.c | 27 +++++++++++++++++++++++++++
commit.h | 2 ++
sequencer.c | 27 ---------------------------
3 files changed, 29 insertions(+), 27 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;
+}
diff --git a/commit.h b/commit.h
index f8d250d..bd17770 100644
--- a/commit.h
+++ b/commit.h
@@ -53,6 +53,8 @@ int find_commit_subject(const char *commit_buffer, const char **subject);
struct commit_list *commit_list_insert(struct commit *item,
struct commit_list **list);
+struct commit_list **commit_list_append(struct commit *commit,
+ struct commit_list **next);
unsigned commit_list_count(const struct commit_list *l);
struct commit_list *commit_list_insert_by_date(struct commit *item,
struct commit_list **list);
diff --git a/sequencer.c b/sequencer.c
index 4307364..ac6c823 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -468,33 +468,6 @@ static void read_and_refresh_cache(struct replay_opts *opts)
rollback_lock_file(&index_lock);
}
-/*
- * 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;
- */
-static 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;
-}
-
static int format_todo(struct strbuf *buf, struct commit_list *todo_list,
struct replay_opts *opts)
{
--
1.7.10
next prev parent reply other threads:[~2012-04-25 20:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-25 7:59 Possible segfault introduced in commit.c Michael Mueller
2012-04-25 11:14 ` Jeff King
2012-04-25 20:22 ` René Scharfe
2012-04-25 20:35 ` René Scharfe [this message]
2012-04-25 22:03 ` [PATCH 1/3] sequencer: export commit_list_append() Junio C Hamano
2012-04-30 21:07 ` René Scharfe
2012-04-25 20:35 ` [PATCH 2/3] revision: append to list instead of insert and reverse René Scharfe
2012-04-25 20:35 ` [PATCH 3/3] commit: remove commit_list_reverse() René Scharfe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F98600F.6000404@lsrfire.ath.cx \
--to=rene.scharfe@lsrfire.ath.cx \
--cc=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mmueller@vigilantsw.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.