commit - 36f93b25da24c22c2fa19fdcf274b80b663083d3
commit + 515d451f3ad6aff3d0b4148d7e6234bddbe17447
blob - 1d6840ec3d3bc9318e74417e89f1c1056a322dd0
blob + 1e8529631deb6fd7186aa4d6f16c12bdba584f78
--- lib/got_lib_object_create.h
+++ lib/got_lib_object_create.h
*/
const struct got_error *got_object_blob_file_create(struct got_object_id **,
- FILE **, off_t *, const char *);
+ FILE **, off_t *, const char *, struct got_repository *);
const struct got_error *got_object_blob_create(struct got_object_id **,
const char *, struct got_repository *);
blob - 31061919e0541beda09a3d663aa5909ef9240853
blob + c3f64cf304de14ee32b20d2d42f888f38bec81a0
--- lib/object_create.c
+++ lib/object_create.c
const struct got_error *
got_object_blob_file_create(struct got_object_id **id, FILE **blobfile,
- off_t *blobsize, const char *ondisk_path)
+ off_t *blobsize, const char *ondisk_path, struct got_repository *repo)
{
const struct got_error *err = NULL;
char *header = NULL;
*blobfile = NULL;
*blobsize = 0;
- got_hash_init(&ctx, GOT_HASH_SHA1);
+ got_hash_init(&ctx, got_repo_get_object_format(repo));
fd = open(ondisk_path, O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
if (fd == -1) {
off_t blobsize;
err = got_object_blob_file_create(id, &blobfile, &blobsize,
- ondisk_path);
+ ondisk_path, repo);
if (err)
return err;
char modebuf[sizeof("100644 ")];
struct got_hash ctx;
char *header = NULL;
- size_t headerlen, len = 0, n;
+ size_t headerlen, len = 0, n, digest_len;
FILE *treefile = NULL;
off_t treesize = 0;
struct got_pathlist_entry *pe;
struct got_tree_entry **sorted_entries;
struct got_tree_entry *te;
+ enum got_hash_algorithm algo;
int i;
*id = NULL;
- got_hash_init(&ctx, GOT_HASH_SHA1);
+ algo = got_repo_get_object_format(repo);
+ digest_len = got_hash_digest_length(algo);
+ got_hash_init(&ctx, algo);
sorted_entries = calloc(nentries, sizeof(struct got_tree_entry *));
if (sorted_entries == NULL)
err = te_mode2str(modebuf, sizeof(modebuf), te);
if (err)
goto done;
- len += strlen(modebuf) + strlen(te->name) + 1 +
- SHA1_DIGEST_LENGTH;
+ len += strlen(modebuf) + strlen(te->name) + 1 + digest_len;
}
if (asprintf(&header, "%s %zd", GOT_OBJ_LABEL_TREE, len) == -1) {
got_hash_update(&ctx, te->name, len);
treesize += n;
- len = SHA1_DIGEST_LENGTH;
+ len = digest_len;
n = fwrite(te->id.hash, 1, len, treefile);
if (n != len) {
err = got_ferror(treefile, GOT_ERR_IO);
char *header = NULL, *tree_str = NULL;
char *author_str = NULL, *committer_str = NULL;
char *id_str = NULL;
- size_t headerlen, len = 0, n;
+ size_t headerlen, len = 0, n, digest_string_len;
FILE *commitfile = NULL;
off_t commitsize = 0;
struct got_object_qid *qid;
+ enum got_hash_algorithm algo;
char *msg0, *msg;
*id = NULL;
- got_hash_init(&ctx, GOT_HASH_SHA1);
+ algo = got_repo_get_object_format(repo);
+ digest_string_len = got_hash_digest_string_length(algo);
+ got_hash_init(&ctx, algo);
msg0 = strdup(logmsg);
if (msg0 == NULL)
goto done;
}
- len = strlen(GOT_COMMIT_LABEL_TREE) + SHA1_DIGEST_STRING_LENGTH +
+ len = strlen(GOT_COMMIT_LABEL_TREE) + digest_string_len +
nparents *
- (strlen(GOT_COMMIT_LABEL_PARENT) + SHA1_DIGEST_STRING_LENGTH) +
+ (strlen(GOT_COMMIT_LABEL_PARENT) + digest_string_len) +
+ strlen(author_str) + strlen(committer_str) + 2 + strlen(msg);
if (asprintf(&header, "%s %zd", GOT_OBJ_LABEL_COMMIT, len) == -1) {
*id = NULL;
- got_hash_init(&ctx, GOT_HASH_SHA1);
+ got_hash_init(&ctx, got_repo_get_object_format(repo));
err = got_object_id_str(&id_str, object_id);
if (err)
blob - f8fe93f31799702eec55f05580d2fcddb9f66464
blob + 94cb5018eb8bd148ea52e237479e027fabca1b14
--- lib/worktree.c
+++ lib/worktree.c
* exists in the repository.
*/
err = got_object_blob_file_create(&id, &blob1_f,
- &blob1_size, path1);
+ &blob1_size, path1, repo);
if (err)
goto done;
if (fclose(blob1_f) == EOF) {
* exists in the repository.
*/
err = got_object_blob_file_create(&id, &blob1_f,
- &blob1_size, path1);
+ &blob1_size, path1, repo);
if (err)
goto done;
if (fclose(blob1_f) == EOF) {