summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-12-11 11:14:12 -0800
committerJunio C Hamano <gitster@pobox.com>2015-12-11 11:14:13 -0800
commit0af22d6fffe5169f641fb9815468ae97e47cd73f (patch)
treee61f2ffb0f66e0d8c5892c0795b6f8a521e4f2c9 /commit.c
parent8c0a546670a2cb2349c5baedbf4b87268e52c665 (diff)
parente510ab898865fdaf131e9bc9fd6ab6b7c4a94c9b (diff)
downloadgit-0af22d6fffe5169f641fb9815468ae97e47cd73f.tar.gz
Merge branch 'rs/pop-commit' into maint
Code simplification. * rs/pop-commit: use pop_commit() for consuming the first entry of a struct commit_list
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 494615d6ff..d1810c940b 100644
--- a/commit.c
+++ b/commit.c
@@ -455,11 +455,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)
@@ -505,12 +502,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;
@@ -861,11 +854,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;
}
@@ -1546,13 +1537,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 */