Commit Diff


commit - 571192ee62db3f420ed381ee3077b9a7cf9eef92
commit + 8fdd8178257524a92d71c6b4a52984f8974f04df
blob - f06337e95fa7c9e3eabd7ab414f3060e6755265a
blob + 6562cd897111bbf157c2279bd29af3e12fe3aa1a
--- gotd/repo_write.c
+++ gotd/repo_write.c
@@ -516,7 +516,8 @@ protect_require_yca(struct got_object_id *tip_id,
 			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
@@ -366,7 +366,7 @@ const char *got_object_tag_get_tagger(struct got_tag_o
 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
@@ -22,7 +22,7 @@ struct got_commit_object *got_object_commit_alloc_part
 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);
 
@@ -35,12 +35,12 @@ struct got_parsed_tree_entry {
 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
@@ -428,7 +428,7 @@ open_commit(struct got_commit_object **commit,
 		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;
@@ -525,7 +525,7 @@ open_tree(struct got_tree_object **tree,
 		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) {
@@ -921,7 +921,7 @@ open_tag(struct got_tag_object **tag, struct got_repos
 		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
@@ -333,7 +333,7 @@ got_object_commit_alloc_partial(void)
 
 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;
@@ -342,7 +342,7 @@ got_object_commit_add_parent(struct got_commit_object 
 	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;
@@ -572,10 +572,9 @@ got_object_commit_get_logmsg_raw(struct got_commit_obj
 
 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;
@@ -614,7 +613,7 @@ got_object_parse_commit(struct got_commit_object **com
 			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;
 
@@ -739,7 +738,8 @@ got_object_read_commit(struct got_commit_object **comm
 
 	/* 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)
@@ -807,7 +807,8 @@ pte_cmp(const void *pa, const void *pb)
 
 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;
@@ -815,7 +816,7 @@ got_object_parse_tree(struct got_parsed_tree_entry **e
 	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)
@@ -907,7 +908,7 @@ got_object_read_tree(struct got_parsed_tree_entry **en
 	/* 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);
@@ -930,10 +931,10 @@ got_object_tag_close(struct got_tag_object *tag)
 }
 
 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;
@@ -1147,7 +1148,8 @@ got_object_read_tag(struct got_tag_object **tag, int f
 
 	/* 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
@@ -144,7 +144,7 @@ open_commit(struct got_commit_object **commit, struct 
 
 	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);
@@ -247,7 +247,7 @@ tree_request(struct imsg *imsg, struct imsgbuf *ibuf, 
 		return err;
 
 	err = got_object_parse_tree(entries, nentries, nentries_alloc,
-	    buf, len);
+	    buf, len, GOT_HASH_SHA1);
 	if (err)
 		goto done;
 
@@ -424,7 +424,7 @@ tag_request(struct imsg *imsg, struct imsgbuf *ibuf, s
 		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;
 
@@ -1257,7 +1257,7 @@ enumerate_tree(int *have_all_entries, struct imsgbuf *
 		}
 
 		err = got_object_parse_tree(&entries, &nentries,
-		    &nentries_alloc, buf, len);
+		    &nentries_alloc, buf, len, GOT_HASH_SHA1);
 		if (err)
 			goto done;
 
@@ -1468,7 +1468,8 @@ enumeration_request(struct imsg *imsg, struct imsgbuf 
 			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;