Commit Diff


commit - 722e143e83970668f8d410884c5d329073524057
commit + 510b45554017ce0a907a5c11a24266600eab5783
blob - a7909cda7bea938e35a6993ddcec3881ec5c7df1
blob + 1c4f5ef4003d20c175c7cccfb4dd5cf5a9f79c80
--- gotd/session.c
+++ gotd/session.c
@@ -408,7 +408,6 @@ update_ref(int *shut, struct gotd_session_client *clie
 	struct gotd_imsg_ref_update iref;
 	struct got_object_id old_id, new_id;
 	struct got_object_id *id = NULL;
-	struct got_object *obj = NULL;
 	char *refname = NULL;
 	size_t datalen;
 	int locked = 0;
@@ -438,8 +437,8 @@ update_ref(int *shut, struct gotd_session_client *clie
 
 	memcpy(old_id.sha1, iref.old_id, SHA1_DIGEST_LENGTH);
 	memcpy(new_id.sha1, iref.new_id, SHA1_DIGEST_LENGTH);
-	err = got_object_open(&obj, repo,
-	    iref.delete_ref ? &old_id : &new_id);
+	err = got_repo_find_object_id(iref.delete_ref ? &old_id : &new_id,
+	    repo);
 	if (err)
 		goto done;
 
@@ -558,8 +557,6 @@ done:
 	}
 	if (ref)
 		got_ref_close(ref);
-	if (obj)
-		got_object_close(obj);
 	if (repo)
 		got_repo_close(repo);
 	free(refname);
blob - f44259d099d9b70c547d238971a7cc147c4e209f
blob + 606d32e822167999828d4333a09b3b6ee296bf61
--- lib/got_lib_repository.h
+++ lib/got_lib_repository.h
@@ -184,3 +184,6 @@ const struct got_error *got_repo_read_gitconfig(int *,
 const struct got_error *got_repo_temp_fds_get(int *, int *,
     struct got_repository *);
 void got_repo_temp_fds_put(int, struct got_repository *);
+
+const struct got_error *got_repo_find_object_id(struct got_object_id *,
+    struct got_repository *);
blob - 3796a21b865387c428d693bce9a05fd8de6779fa
blob + d33d541d933aef39d8511a0f97db12f13b32ac22
--- lib/repository.c
+++ lib/repository.c
@@ -2153,7 +2153,24 @@ got_repo_object_match_tag(struct got_tag_object **tag,
 		    GOT_OBJ_LABEL_TAG, name);
 	return err;
 }
+
+const struct got_error *
+got_repo_find_object_id(struct got_object_id *id, struct got_repository *repo)
+{
+	const struct got_error *err;
+	struct got_object_id *matched_id = NULL;
+	char *id_str = NULL;
 
+	err = got_object_id_str(&id_str, id);
+	if (err)
+		return err;
+
+	err = got_repo_match_object_id_prefix(&matched_id, id_str,
+	    GOT_OBJ_TYPE_ANY, repo);
+	free(id_str);
+	return err;
+}
+
 static const struct got_error *
 alloc_added_blob_tree_entry(struct got_tree_entry **new_te,
     const char *name, mode_t mode, struct got_object_id *blob_id)