summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2015-10-24 16:21:31 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-10-26 21:06:46 (GMT)
commite510ab898865fdaf131e9bc9fd6ab6b7c4a94c9b (patch)
treee189dbe7cc56b89b1d8c2e1d884db8d1da6e4a8b /commit.c
parent24358560c3c0ab51c9ef8178d99f46711716f6c0 (diff)
downloadgit-e510ab898865fdaf131e9bc9fd6ab6b7c4a94c9b.zip
git-e510ab898865fdaf131e9bc9fd6ab6b7c4a94c9b.tar.gz
git-e510ab898865fdaf131e9bc9fd6ab6b7c4a94c9b.tar.bz2
use pop_commit() for consuming the first entry of a struct commit_list
Instead of open-coding the function pop_commit() just call it. This makes the intent clearer and reduces code size. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/commit.c b/commit.c
index 6e2103c..1ab4ff2 100644
--- a/commit.c
+++ b/commit.c
@@ -443,11 +443,8 @@ struct commit_list *copy_commit_list(struct commit_list *list)
void free_commit_list(struct commit_list *list)
{
- while (list) {
- struct commit_list *temp = list;
- list = temp->next;
- free(temp);
- }
+ while (list)
+ pop_commit(&list);
}
struct commit_list * commit_list_insert_by_date(struct commit *item, struct commit_list **list)
@@ -493,12 +490,8 @@ void commit_list_sort_by_date(struct commit_list **list)
struct commit *pop_most_recent_commit(struct commit_list **list,
unsigned int mark)
{
- struct commit *ret = (*list)->item;
+ struct commit *ret = pop_commit(list);
struct commit_list *parents = ret->parents;
- struct commit_list *old = *list;
-
- *list = (*list)->next;
- free(old);
while (parents) {
struct commit *commit = parents->item;
@@ -849,11 +842,9 @@ static struct commit_list *merge_bases_many(struct commit *one, int n, struct co
list = paint_down_to_common(one, n, twos);
while (list) {
- struct commit_list *next = list->next;
- if (!(list->item->object.flags & STALE))
- commit_list_insert_by_date(list->item, &result);
- free(list);
- list = next;
+ struct commit *commit = pop_commit(&list);
+ if (!(commit->object.flags & STALE))
+ commit_list_insert_by_date(commit, &result);
}
return result;
}
@@ -1543,13 +1534,9 @@ int commit_tree_extended(const char *msg, size_t msg_len,
* if everything else stays the same.
*/
while (parents) {
- struct commit_list *next = parents->next;
- struct commit *parent = parents->item;
-
+ struct commit *parent = pop_commit(&parents);
strbuf_addf(&buffer, "parent %s\n",
sha1_to_hex(parent->object.sha1));
- free(parents);
- parents = next;
}
/* Person/date information */