Commit f8e900f3dec31fd1b679afff508f7c5e33d73956

Stefan Sperling 2018-06-11T03:33:43

use got_object_open_as_commit() in 'got log'

diff --git a/got/got.c b/got/got.c
index a4853d1..57706b2 100644
--- a/got/got.c
+++ b/got/got.c
@@ -388,7 +388,6 @@ print_commits(struct got_object *root_obj, struct got_object_id *root_id,
 	if (err)
 		return err;
 	do {
-		struct got_object *obj;
 		struct got_commit_object *commit;
 		struct got_object_id *id;
 
@@ -405,15 +404,10 @@ print_commits(struct got_object *root_obj, struct got_object_id *root_id,
 		}
 		if (id == NULL)
 			break;
-		err = got_object_open(&obj, repo, id);
-		if (err)
-			return err;
 
-		err = got_object_commit_open(&commit, repo, obj);
-		got_object_close(obj);
+		err = got_object_open_as_commit(&commit, repo, id);
 		if (err)
 			return err;
-
 		err = print_commit(commit, id, repo, show_patch, verbose);
 		got_object_commit_close(commit);
 		if (err || (limit && --limit == 0))