commit dfe0a3d83340456fd269a59991dc47c4ac7e3ad3 from: Omar Polo date: Sat Feb 04 16:18:44 2023 UTC set id.algo in a few places where it was undefined commit - ffcada4305d6b134e214790fa1e74873e36484fb commit + dfe0a3d83340456fd269a59991dc47c4ac7e3ad3 blob - 559839987c1189a29404277bd6cfc773f938df71 blob + 673fbab9bb8b4be2c1fa2678831d61531cc03a34 --- lib/object_create.c +++ lib/object_create.c @@ -205,6 +205,7 @@ got_object_blob_file_create(struct got_object_id **id, goto done; } SHA1Final((*id)->hash, &hash_ctx); + (*id)->algo = GOT_HASH_SHA1; if (fflush(*blobfile) != 0) { err = got_error_from_errno("fflush"); @@ -399,6 +400,7 @@ got_object_tree_create(struct got_object_id **id, goto done; } SHA1Final((*id)->hash, &hash_ctx); + (*id)->algo = GOT_HASH_SHA1; if (fflush(treefile) != 0) { err = got_error_from_errno("fflush"); @@ -588,6 +590,7 @@ got_object_commit_create(struct got_object_id **id, goto done; } SHA1Final((*id)->hash, &hash_ctx); + (*id)->algo = GOT_HASH_SHA1; if (fflush(commitfile) != 0) { err = got_error_from_errno("fflush"); @@ -855,6 +858,7 @@ got_object_tag_create(struct got_object_id **id, goto done; } SHA1Final((*id)->hash, &hash_ctx); + (*id)->algo = GOT_HASH_SHA1; if (fflush(tagfile) != 0) { err = got_error_from_errno("fflush"); blob - a8c4aac0b9ae220bc77e40c1222dbee1ca8c14ed blob + 12b9dc0ae6a49c8188054c596ce11355019ce40f --- lib/repository.c +++ lib/repository.c @@ -1736,7 +1736,8 @@ match_loose_object(struct got_object_id **unique_id, c goto done; } - if (!got_parse_sha1_digest(id.hash, id_str)) + id.algo = repo->algo; + if (!got_parse_hash_digest(id.hash, id_str, repo->algo, NULL)) continue; /* @@ -2272,6 +2273,7 @@ got_repo_get_loose_object_info(int *nobjects, off_t *o goto done; } + /* XXX: sha256 */ if (!got_parse_sha1_digest(id.hash, id_str)) { free(id_str); continue; blob - 79eb9116f97c5351fb550525e0bbaac32aa1ced3 blob + 55931cbfebbf7bac51d26d273c8e79721f75e874 --- lib/worktree.c +++ lib/worktree.c @@ -64,6 +64,8 @@ #define GOT_MERGE_LABEL_MERGED "merged change" #define GOT_MERGE_LABEL_BASE "3-way merge base" + +#define WORKTREE_ALGO(wt) ((wt)->base_commit_id->algo) static mode_t apply_umask(mode_t); @@ -1932,6 +1934,7 @@ update_blob(struct got_worktree *worktree, } struct got_object_id id2; memcpy(id2.hash, ie->blob_hash, SHA1_DIGEST_LENGTH); + id2.algo = got_repo_get_hash_algorithm(repo); err = got_object_open_as_blob(&blob2, repo, &id2, 8192, fd2); if (err) @@ -3347,16 +3350,19 @@ report_file_status(struct got_fileindex_entry *ie, con if (got_fileindex_entry_has_blob(ie)) { memcpy(blob_id.hash, ie->blob_hash, SHA1_DIGEST_LENGTH); + blob_id.algo = got_repo_get_hash_algorithm(repo); blob_idp = &blob_id; } if (got_fileindex_entry_has_commit(ie)) { memcpy(commit_id.hash, ie->commit_hash, SHA1_DIGEST_LENGTH); + commit_id.algo = got_repo_get_hash_algorithm(repo); commit_idp = &commit_id; } if (staged_status == GOT_STATUS_ADD || staged_status == GOT_STATUS_MODIFY) { memcpy(staged_blob_id.hash, ie->staged_blob_hash, SHA1_DIGEST_LENGTH); + staged_blob_id.algo = got_repo_get_hash_algorithm(repo); staged_blob_idp = &staged_blob_id; } @@ -3410,7 +3416,9 @@ status_old(void *arg, struct got_fileindex_entry *ie, return NULL; memcpy(blob_id.hash, ie->blob_hash, SHA1_DIGEST_LENGTH); + blob_id.algo = got_repo_get_hash_algorithm(a->repo); memcpy(commit_id.hash, ie->commit_hash, SHA1_DIGEST_LENGTH); + commit_id.algo = got_repo_get_hash_algorithm(a->repo); if (got_fileindex_entry_has_file_on_disk(ie)) status = GOT_STATUS_MISSING; else @@ -4790,6 +4798,8 @@ revert_file(void *arg, unsigned char status, unsigned } else memcpy(id.hash, ie->blob_hash, SHA1_DIGEST_LENGTH); + id.algo = got_repo_get_hash_algorithm(a->repo); + fd = got_opentempfd(); if (fd == -1) { err = got_error_from_errno("got_opentempfd"); @@ -8286,6 +8296,7 @@ check_stage_ok(void *arg, unsigned char status, if (got_fileindex_entry_has_commit(ie)) { memcpy(base_commit_id.hash, ie->commit_hash, SHA1_DIGEST_LENGTH); + base_commit_id.algo = got_repo_get_hash_algorithm(a->repo); base_commit_idp = &base_commit_id; } @@ -9120,6 +9131,7 @@ report_file_info(void *arg, struct got_fileindex_entry if (got_fileindex_entry_has_blob(ie)) { memcpy(blob_id.hash, ie->blob_hash, SHA1_DIGEST_LENGTH); + blob_id.algo = WORKTREE_ALGO(a->worktree); blob_idp = &blob_id; } stage = got_fileindex_entry_stage_get(ie); @@ -9127,11 +9139,13 @@ report_file_info(void *arg, struct got_fileindex_entry stage == GOT_FILEIDX_STAGE_ADD) { memcpy(staged_blob_id.hash, ie->staged_blob_hash, SHA1_DIGEST_LENGTH); + staged_blob_id.algo = WORKTREE_ALGO(a->worktree); staged_blob_idp = &staged_blob_id; } if (got_fileindex_entry_has_commit(ie)) { memcpy(commit_id.hash, ie->commit_hash, SHA1_DIGEST_LENGTH); + commit_id.algo = WORKTREE_ALGO(a->worktree); commit_idp = &commit_id; }