Commit ded8fbb852004c3af2b31b1286f4fcfb50b998ba

Stefan Sperling 2020-04-19T08:57:07

include the relevant object ID in NO_OBJ error messages where possible

diff --git a/lib/object_idset.c b/lib/object_idset.c
index 510b59e..9c29655 100644
--- a/lib/object_idset.c
+++ b/lib/object_idset.c
@@ -150,7 +150,7 @@ got_object_idset_remove(void **data, struct got_object_idset *set,
 	else
 		entry = find_element(set, id);
 	if (entry == NULL)
-		return got_error(GOT_ERR_NO_OBJ);
+		return got_error_no_obj(id);
 
 	RB_REMOVE(got_object_idset_tree, &set->entries, entry);
 	if (data)
diff --git a/lib/repository.c b/lib/repository.c
index 82d26fe..7531c15 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -1432,7 +1432,7 @@ got_repo_object_match_tag(struct got_tag_object **tag, const char *name,
 
 	got_ref_list_free(&refs);
 	if (err == NULL && *tag == NULL)
-		err = got_error(GOT_ERR_NO_OBJ);
+		err = got_error_path(name, GOT_ERR_NO_OBJ);
 	return err;
 }
 
diff --git a/libexec/got-read-pack/got-read-pack.c b/libexec/got-read-pack/got-read-pack.c
index b66f606..599d059 100644
--- a/libexec/got-read-pack/got-read-pack.c
+++ b/libexec/got-read-pack/got-read-pack.c
@@ -497,13 +497,13 @@ tree_path_changed(int *changed, uint8_t **buf1, uint8_t **buf2,
 			struct got_object_id id1, id2;
 			int idx;
 
+			memcpy(id1.sha1, pte1->id, SHA1_DIGEST_LENGTH);
 			idx = got_packidx_get_object_idx_sha1(packidx,
 			    pte1->id);
 			if (idx == -1) {
-				err = got_error(GOT_ERR_NO_OBJ);
+				err = got_error_no_obj(&id1);
 				break;
 			}
-			memcpy(id1.sha1, pte1->id, SHA1_DIGEST_LENGTH);
 			got_object_parsed_tree_entries_free(entries1);
 			*nentries1 = 0;
 			free(*buf1);
@@ -514,13 +514,13 @@ tree_path_changed(int *changed, uint8_t **buf1, uint8_t **buf2,
 			if (err)
 				break;
 
+			memcpy(id2.sha1, pte2->id, SHA1_DIGEST_LENGTH);
 			idx = got_packidx_get_object_idx_sha1(packidx,
 			    pte2->id);
 			if (idx == -1) {
-				err = got_error(GOT_ERR_NO_OBJ);
+				err = got_error_no_obj(&id2);
 				break;
 			}
-			memcpy(id2.sha1, pte2->id, SHA1_DIGEST_LENGTH);
 			got_object_parsed_tree_entries_free(entries2);
 			*nentries2 = 0;
 			free(*buf2);