commit - 571192ee62db3f420ed381ee3077b9a7cf9eef92
commit + 8fdd8178257524a92d71c6b4a52984f8974f04df
blob - f06337e95fa7c9e3eabd7ab414f3060e6755265a
blob + 6562cd897111bbf157c2279bd29af3e12fe3aa1a
--- gotd/repo_write.c
+++ gotd/repo_write.c
if (err)
goto done;
- err = got_object_parse_commit(&commit, buf, len);
+ err = got_object_parse_commit(&commit, buf, len,
+ GOT_HASH_SHA1);
if (err)
goto done;
blob - 7672f9da04d627c9c0d625a0aeafe03183f72626
blob + 32187d2046b3c350e8f51ea150d5f082f79ad56b
--- include/got_object.h
+++ include/got_object.h
const char *got_object_tag_get_message(struct got_tag_object *);
const struct got_error *got_object_commit_add_parent(struct got_commit_object *,
- const char *);
+ const char *, enum got_hash_algorithm);
/* Create a new tag object in the repository. */
const struct got_error *got_object_tag_create(struct got_object_id **,
blob - f871e8cb69954a7bce76347100e63673a2c8fd95
blob + 05babbcb9ae24c765e1ed59bf0cb51d45de5aec7
--- lib/got_lib_object_parse.h
+++ lib/got_lib_object_parse.h
struct got_tree_entry *got_alloc_tree_entry_partial(void);
const struct got_error *got_object_parse_commit(struct got_commit_object **,
- char *, size_t);
+ char *, size_t, enum got_hash_algorithm);
const struct got_error *got_object_read_commit(struct got_commit_object **, int,
struct got_object_id *, size_t);
const struct got_error *got_object_parse_tree_entry(
struct got_parsed_tree_entry *, size_t *, char *, size_t, size_t);
const struct got_error *got_object_parse_tree(struct got_parsed_tree_entry **,
- size_t *, size_t *, uint8_t *, size_t);
+ size_t *, size_t *, uint8_t *, size_t, enum got_hash_algorithm);
const struct got_error *got_object_read_tree(struct got_parsed_tree_entry **,
size_t *, size_t *, uint8_t **, int, struct got_object_id *);
const struct got_error *got_object_parse_tag(struct got_tag_object **,
- uint8_t *, size_t);
+ uint8_t *, size_t, enum got_hash_algorithm);
const struct got_error *got_object_read_tag(struct got_tag_object **, int,
struct got_object_id *, size_t);
blob - f786101c27c52e49d41dab5ca56ae883ecf272a5
blob + a18b2539b7434d2225f3d7b94c76e7dbad21999b
--- lib/object_open_io.c
+++ lib/object_open_io.c
got_object_close(obj);
if (err)
goto done;
- err = got_object_parse_commit(commit, buf, len);
+ err = got_object_parse_commit(commit, buf, len, GOT_HASH_SHA1);
free(buf);
} else if (err->code == GOT_ERR_NO_OBJ) {
int fd;
if (err)
goto done;
err = got_object_parse_tree(&entries, &nentries,
- &nentries_alloc, buf, len);
+ &nentries_alloc, buf, len, GOT_HASH_SHA1);
if (err)
goto done;
} else if (err->code == GOT_ERR_NO_OBJ) {
got_object_close(obj);
if (err)
goto done;
- err = got_object_parse_tag(tag, buf, len);
+ err = got_object_parse_tag(tag, buf, len, GOT_HASH_SHA1);
free(buf);
} else if (err->code == GOT_ERR_NO_OBJ) {
int fd;
blob - f3cba911b4349a33264333ee8d8e133f09221710
blob + 3a7d1e49be0e4a6882f9313120d6973a76f063f9
--- lib/object_parse.c
+++ lib/object_parse.c
const struct got_error *
got_object_commit_add_parent(struct got_commit_object *commit,
- const char *id_str)
+ const char *id_str, enum got_hash_algorithm algo)
{
const struct got_error *err = NULL;
struct got_object_qid *qid;
if (err)
return err;
- if (!got_parse_object_id(&qid->id, id_str, GOT_HASH_SHA1)) {
+ if (!got_parse_object_id(&qid->id, id_str, algo)) {
err = got_error(GOT_ERR_BAD_OBJ_DATA);
got_object_qid_free(qid);
return err;
const struct got_error *
got_object_parse_commit(struct got_commit_object **commit, char *buf,
- size_t len)
+ size_t len, enum got_hash_algorithm algo)
{
const struct got_error *err = NULL;
- enum got_hash_algorithm algo = GOT_HASH_SHA1;
char *s = buf;
size_t label_len;
ssize_t remain = (ssize_t)len;
goto done;
}
s += label_len;
- err = got_object_commit_add_parent(*commit, s);
+ err = got_object_commit_add_parent(*commit, s, algo);
if (err)
goto done;
/* Skip object header. */
len -= obj->hdrlen;
- err = got_object_parse_commit(commit, p + obj->hdrlen, len);
+ err = got_object_parse_commit(commit, p + obj->hdrlen, len,
+ GOT_HASH_SHA1);
done:
free(p);
if (obj)
const struct got_error *
got_object_parse_tree(struct got_parsed_tree_entry **entries, size_t *nentries,
- size_t *nentries_alloc, uint8_t *buf, size_t len)
+ size_t *nentries_alloc, uint8_t *buf, size_t len,
+ enum got_hash_algorithm algo)
{
const struct got_error *err = NULL;
size_t idlen, remain = len;
struct got_parsed_tree_entry *pte;
int i;
- idlen = got_hash_digest_length(GOT_HASH_SHA1);
+ idlen = got_hash_digest_length(algo);
*nentries = 0;
if (remain == 0)
/* Skip object header. */
len -= obj->hdrlen;
err = got_object_parse_tree(entries, nentries, nentries_alloc,
- *p + obj->hdrlen, len);
+ *p + obj->hdrlen, len, GOT_HASH_SHA1);
done:
if (obj)
got_object_close(obj);
}
const struct got_error *
-got_object_parse_tag(struct got_tag_object **tag, uint8_t *buf, size_t len)
+got_object_parse_tag(struct got_tag_object **tag, uint8_t *buf, size_t len,
+ enum got_hash_algorithm algo)
{
const struct got_error *err = NULL;
- enum got_hash_algorithm algo = GOT_HASH_SHA1;
size_t remain = len;
char *s = buf;
size_t label_len;
/* Skip object header. */
len -= obj->hdrlen;
- err = got_object_parse_tag(tag, p + obj->hdrlen, len);
+ err = got_object_parse_tag(tag, p + obj->hdrlen, len,
+ GOT_HASH_SHA1);
done:
free(p);
if (obj)
blob - e55cdb411d26905c5b5b6fcb06e7fe199e96521f
blob + 460b92c34a33a3c21a304ba83a835391f3b6db31
--- libexec/got-read-pack/got-read-pack.c
+++ libexec/got-read-pack/got-read-pack.c
obj->size = len;
- err = got_object_parse_commit(commit, buf, len);
+ err = got_object_parse_commit(commit, buf, len, pack->algo);
done:
got_object_close(obj);
free(buf);
return err;
err = got_object_parse_tree(entries, nentries, nentries_alloc,
- buf, len);
+ buf, len, GOT_HASH_SHA1);
if (err)
goto done;
goto done;
obj->size = len;
- err = got_object_parse_tag(&tag, buf, len);
+ err = got_object_parse_tag(&tag, buf, len, GOT_HASH_SHA1);
if (err)
goto done;
}
err = got_object_parse_tree(&entries, &nentries,
- &nentries_alloc, buf, len);
+ &nentries_alloc, buf, len, GOT_HASH_SHA1);
if (err)
goto done;
if (err)
goto done;
obj->size = len;
- err = got_object_parse_tag(&tag, buf, len);
+ err = got_object_parse_tag(&tag, buf, len,
+ GOT_HASH_SHA1);
if (err) {
free(buf);
goto done;