Commit 675d71c4343c11708d0df6b8965cb4e6f3a42ea2

Stefan Sperling 2018-04-02T21:14:21

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;