commit - baf338b8486ea41a65c0a04ae966baf3d6bb5ff0
commit + 328dced4dbb88dad76d7c9ef102057498e2b2ace
blob - 6ce635e299cfb8a3b1d2cc29df47893282d7e9e6
blob + acf36dbaeeb41157de520367ebbdeaa24ba2ce67
--- lib/object.c
+++ lib/object.c
got_object_open_by_id_str(struct got_object **obj, struct got_repository *repo,
const char *id_str)
{
- struct got_object_id id;
+ struct got_object_id id = { .algo = repo->algo };
- if (!got_parse_sha1_digest(id.hash, id_str))
+ if (repo->algo == GOT_HASH_SHA256) {
+ if (!got_parse_sha256_digest(id.hash, id_str))
+ return got_error_path(id_str, GOT_ERR_BAD_OBJ_ID_STR);
+ } else if (repo->algo == GOT_HASH_SHA1) {
+ if (!got_parse_sha1_digest(id.hash, id_str))
+ return got_error_path(id_str, GOT_ERR_BAD_OBJ_ID_STR);
+ } else
return got_error_path(id_str, GOT_ERR_BAD_OBJ_ID_STR);
return got_object_open(obj, repo, &id);