clean up commit list in print_commits() regardless of error
diff --git a/got/got.c b/got/got.c
index bbfab87..46570b4 100644
--- a/got/got.c
+++ b/got/got.c
@@ -413,14 +413,12 @@ print_commits(struct got_object *root_obj, struct got_object_id *root_id,
free(entry);
}
- if (err) {
- while (!TAILQ_EMPTY(&commits)) {
- entry = TAILQ_FIRST(&commits);
- TAILQ_REMOVE(&commits, entry, entry);
- got_object_commit_close(entry->commit);
- free(entry->id);
- free(entry);
- }
+ while (!TAILQ_EMPTY(&commits)) {
+ entry = TAILQ_FIRST(&commits);
+ TAILQ_REMOVE(&commits, entry, entry);
+ got_object_commit_close(entry->commit);
+ free(entry->id);
+ free(entry);
}
return err;