commit 36f93b25da24c22c2fa19fdcf274b80b663083d3 from: Omar Polo date: Tue Jul 16 12:12:11 2024 UTC fileindex: improve unexpected object-format error message suggested by stsp commit - 5bbd34eadb5ecb96d4863dbd7e83a180574a9f7d commit + 36f93b25da24c22c2fa19fdcf274b80b663083d3 blob - 297838cf266397d54bdb3a828d279dce115a0c86 blob + 25b4a291714dfe97961ac61b9f0ac9b1954c8d05 --- lib/fileindex.c +++ lib/fileindex.c @@ -746,9 +746,16 @@ got_fileindex_read(struct got_fileindex *fileindex, FI return got_ferror(infile, GOT_ERR_FILEIDX_BAD); } algo = be32toh(hdr.algo); - if (algo != repo_algo) - return got_error_fmt(GOT_ERR_OBJECT_FORMAT, - "unknown object format"); + if (algo != repo_algo) { + const char *fmt = "unknown"; + + if (repo_algo == GOT_HASH_SHA1) + fmt = "sha1"; + else if (repo_algo == GOT_HASH_SHA256) + fmt = "sha256"; + + return got_error_path(fmt, GOT_ERR_OBJECT_FORMAT); + } } digest_len = got_hash_digest_length(algo);