Commit 6dd1ece69a673273a872d5fb39eb97fc593a6f47

Stefan Sperling 2019-11-10T11:32:03

when an object id string is bad, include the bad string in the error message

diff --git a/lib/object.c b/lib/object.c
index 7f69adc..c6bef75 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -450,7 +450,7 @@ got_object_open_by_id_str(struct got_object **obj, struct got_repository *repo,
 	struct got_object_id id;
 
 	if (!got_parse_sha1_digest(id.sha1, id_str))
-		return got_error(GOT_ERR_BAD_OBJ_ID_STR);
+		return got_error_path(id_str, GOT_ERR_BAD_OBJ_ID_STR);
 
 	return got_object_open(obj, repo, &id);
 }
diff --git a/lib/pack.c b/lib/pack.c
index f4d0993..fb5f114 100644
--- a/lib/pack.c
+++ b/lib/pack.c
@@ -471,13 +471,13 @@ got_packidx_match_id_str_prefix(struct got_object_id_queue *matched_ids,
 	SIMPLEQ_INIT(matched_ids);
 
 	if (prefix_len < 2)
-		return got_error(GOT_ERR_BAD_OBJ_ID_STR);
+		return got_error_path(id_str_prefix, GOT_ERR_BAD_OBJ_ID_STR);
 
 	hex[0] = id_str_prefix[0];
 	hex[1] = id_str_prefix[1];
 	hex[2] = '\0';
 	if (!got_parse_xdigit(&id0, hex))
-		return got_error(GOT_ERR_BAD_OBJ_ID_STR);
+		return got_error_path(id_str_prefix, GOT_ERR_BAD_OBJ_ID_STR);
 
 	i = betoh32(packidx->hdr.fanout_table[id0 - 1]);
 	if (i == 0)
diff --git a/lib/repository.c b/lib/repository.c
index 23d2de6..9dffdcd 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -1246,7 +1246,7 @@ got_repo_match_object_id_prefix(struct got_object_id **id,
 	for (i = 0; i < strlen(id_str_prefix); i++) {
 		if (isxdigit((unsigned char)id_str_prefix[i]))
 			continue;
-		return got_error(GOT_ERR_BAD_OBJ_ID_STR);
+		return got_error_path(id_str_prefix, GOT_ERR_BAD_OBJ_ID_STR);
 	}
 
 	len = strlen(id_str_prefix);
@@ -1279,7 +1279,7 @@ got_repo_match_object_id_prefix(struct got_object_id **id,
 				goto done;
 		}
 	} else {
-		err = got_error(GOT_ERR_BAD_OBJ_ID_STR);
+		err = got_error_path(id_str_prefix, GOT_ERR_BAD_OBJ_ID_STR);
 		goto done;
 	}
 done:
diff --git a/lib/worktree.c b/lib/worktree.c
index 7820150..e841520 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -1297,7 +1297,8 @@ update_blob(struct got_worktree *worktree,
 			char id_str[SHA1_DIGEST_STRING_LENGTH];
 			if (got_sha1_digest_to_str(ie->commit_sha1, id_str,
 			    sizeof(id_str)) == NULL) {
-				err = got_error(GOT_ERR_BAD_OBJ_ID_STR);
+				err = got_error_path(id_str,
+				    GOT_ERR_BAD_OBJ_ID_STR);
 				goto done;
 			}
 			if (asprintf(&label_orig, "%s: commit %s",