Commit Diff


commit - bb7182a5b18165905163dc712f19974358abfe76
commit + e8eb494afad8556bf5105f01c316b49e68ba6842
blob - a72d11debea5876add9fbb37115769267317b374
blob + 5d6b4ff1b5dd49ad7489b12a5a3c1b90d95fa5d2
--- lib/object.c
+++ lib/object.c
@@ -278,7 +278,11 @@ got_object_open_as_commit(struct got_commit_object **c
 	const struct got_error *err;
 	struct got_object *obj;
 
-	*commit = NULL;
+	*commit = got_repo_get_cached_commit(repo, id);
+	if (*commit != NULL) {
+		(*commit)->refcnt++;
+		return NULL;
+	}
 
 	err = got_object_open(&obj, repo, id);
 	if (err)
@@ -405,7 +409,11 @@ got_object_open_as_tree(struct got_tree_object **tree,
 	const struct got_error *err;
 	struct got_object *obj;
 
-	*tree = NULL;
+	*tree = got_repo_get_cached_tree(repo, id);
+	if (*tree != NULL) {
+		(*tree)->refcnt++;
+		return NULL;
+	}
 
 	err = got_object_open(&obj, repo, id);
 	if (err)