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>
This commit is contained in:
René Scharfe
2015-10-24 18:21:31 +02:00
committed by Junio C Hamano
parent 24358560c3
commit e510ab8988
10 changed files with 31 additions and 92 deletions

View File

@ -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 */