commit - 94ef25578c680bc8171b33b5e5b6037f2872abcb
commit + 3093e2d747a41afd623354136331c7babea32ca8
blob - e22197aef200b4b37d02bf22b05649f1af0a55a4
blob + 10dc2d3863fbc6030fffe9d6d2ef29795295e2b9
--- gotd/gotd.h
+++ gotd/gotd.h
/* Structure for GOTD_IMSG_PACKFILE_INSTALL. */
struct gotd_imsg_packfile_install {
uint32_t client_id;
- uint8_t pack_sha1[SHA1_DIGEST_LENGTH];
+ uint8_t pack_hash[SHA1_DIGEST_LENGTH];
};
/* Structure for GOTD_IMSG_PACKFILE_DONE data. */
blob - de57ba5027a29b8074cadbe8bb9367f848c92623
blob + 7f17ae43bae907d9b742a0d4eef1d71f7b35c669
--- gotd/repo_imsg.c
+++ gotd/repo_imsg.c
char hex[SHA1_DIGEST_STRING_LENGTH];
if (log_getverbose() > 0 &&
- got_sha1_digest_to_str(id->sha1, hex, sizeof(hex)))
+ got_sha1_digest_to_str(id->hash, hex, sizeof(hex)))
log_debug("sending ACK for %s", hex);
memset(&iack, 0, sizeof(iack));
- memcpy(iack.object_id, id->sha1, SHA1_DIGEST_LENGTH);
+ memcpy(iack.object_id, id->hash, SHA1_DIGEST_LENGTH);
if (imsg_compose(ibuf, GOTD_IMSG_ACK, peerid, pid, -1,
&iack, sizeof(iack)) == -1) {
char hex[SHA1_DIGEST_STRING_LENGTH];
if (log_getverbose() > 0 &&
- got_sha1_digest_to_str(id->sha1, hex, sizeof(hex)))
+ got_sha1_digest_to_str(id->hash, hex, sizeof(hex)))
log_debug("sending NAK for %s", hex);
memset(&inak, 0, sizeof(inak));
- memcpy(inak.object_id, id->sha1, SHA1_DIGEST_LENGTH);
+ memcpy(inak.object_id, id->hash, SHA1_DIGEST_LENGTH);
if (imsg_compose(ibuf, GOTD_IMSG_NAK, peerid, pid, -1,
&inak, sizeof(inak)) == -1) {
blob - 658362effe9f7a546e607cdc600ad87c21b66f60
blob + 94a242f98628e3612e84539eb09cde4f5a91db10
--- gotd/repo_read.c
+++ gotd/repo_read.c
memset(&isymref, 0, sizeof(isymref));
isymref.name_len = strlen(refname);
isymref.target_len = strlen(target);
- memcpy(isymref.target_id, target_id->sha1, sizeof(isymref.target_id));
+ memcpy(isymref.target_id, target_id->hash, sizeof(isymref.target_id));
len = sizeof(isymref) + isymref.name_len + isymref.target_len;
if (len > MAX_IMSGSIZE - IMSG_HEADER_SIZE) {
}
/* Keep in sync with struct gotd_imsg_ref definition. */
- if (imsg_add(wbuf, id->sha1, SHA1_DIGEST_LENGTH) == -1) {
+ if (imsg_add(wbuf, id->hash, SHA1_DIGEST_LENGTH) == -1) {
err = got_error_from_errno("imsg_add REF");
goto done;
}
}
/* Keep in sync with struct gotd_imsg_ref definition. */
- if (imsg_add(wbuf, id->sha1, SHA1_DIGEST_LENGTH) == -1)
+ if (imsg_add(wbuf, id->hash, SHA1_DIGEST_LENGTH) == -1)
return got_error_from_errno("imsg_add REF");
if (imsg_add(wbuf, &namelen, sizeof(namelen)) == -1)
return got_error_from_errno("imsg_add REF");
memcpy(&iwant, imsg->data, sizeof(iwant));
memset(&id, 0, sizeof(id));
- memcpy(id.sha1, iwant.object_id, SHA1_DIGEST_LENGTH);
+ memcpy(id.hash, iwant.object_id, SHA1_DIGEST_LENGTH);
if (log_getverbose() > 0 &&
- got_sha1_digest_to_str(id.sha1, hex, sizeof(hex)))
+ got_sha1_digest_to_str(id.hash, hex, sizeof(hex)))
log_debug("client wants %s", hex);
imsg_init(&ibuf, client->fd);
memcpy(&ihave, imsg->data, sizeof(ihave));
memset(&id, 0, sizeof(id));
- memcpy(id.sha1, ihave.object_id, SHA1_DIGEST_LENGTH);
+ memcpy(id.hash, ihave.object_id, SHA1_DIGEST_LENGTH);
if (log_getverbose() > 0 &&
- got_sha1_digest_to_str(id.sha1, hex, sizeof(hex)))
+ got_sha1_digest_to_str(id.hash, hex, sizeof(hex)))
log_debug("client has %s", hex);
imsg_init(&ibuf, client->fd);
const struct got_error *err = NULL;
struct repo_read_client *client = &repo_read_client;
struct gotd_imsg_packfile_done idone;
- uint8_t packsha1[SHA1_DIGEST_LENGTH];
+ uint8_t packhash[SHA1_DIGEST_LENGTH];
char hex[SHA1_DIGEST_STRING_LENGTH];
FILE *delta_cache = NULL;
struct imsgbuf ibuf;
pa.ibuf = &ibuf;
pa.report_progress = client->report_progress;
- err = got_pack_create(packsha1, client->pack_pipe, delta_cache,
+ err = got_pack_create(packhash, client->pack_pipe, delta_cache,
client->have_ids.ids, client->have_ids.nids,
client->want_ids.ids, client->want_ids.nids,
repo_read.repo, 0, 1, pack_progress, &pa, &rl,
goto done;
if (log_getverbose() > 0 &&
- got_sha1_digest_to_str(packsha1, hex, sizeof(hex)))
+ got_sha1_digest_to_str(packhash, hex, sizeof(hex)))
log_debug("sent pack-%s.pack", hex);
memset(&idone, 0, sizeof(idone));
blob - b425ba49c41d4c20c076b2c6c6a77b84366abf0d
blob + fee7c5d9cc56be341cedac18180923310351e9b8
--- gotd/repo_write.c
+++ gotd/repo_write.c
int fd;
int pack_pipe;
struct got_pack pack;
- uint8_t pack_sha1[SHA1_DIGEST_LENGTH];
+ uint8_t pack_hash[SHA1_DIGEST_LENGTH];
int packidx_fd;
struct gotd_ref_updates ref_updates;
int nref_updates;
}
/* Keep in sync with struct gotd_imsg_ref definition. */
- if (imsg_add(wbuf, id->sha1, SHA1_DIGEST_LENGTH) == -1) {
+ if (imsg_add(wbuf, id->hash, SHA1_DIGEST_LENGTH) == -1) {
err = got_error_from_errno("imsg_add REF");
goto done;
}
}
/* Keep in sync with struct gotd_imsg_ref definition. */
- if (imsg_add(wbuf, id->sha1, SHA1_DIGEST_LENGTH) == -1)
+ if (imsg_add(wbuf, id->hash, SHA1_DIGEST_LENGTH) == -1)
return got_error_from_errno("imsg_add REF");
if (imsg_add(wbuf, &namelen, sizeof(namelen)) == -1)
return got_error_from_errno("imsg_add REF");
goto done;
}
- memcpy(ref_update->old_id.sha1, iref.old_id, SHA1_DIGEST_LENGTH);
- memcpy(ref_update->new_id.sha1, iref.new_id, SHA1_DIGEST_LENGTH);
+ memcpy(ref_update->old_id.hash, iref.old_id, SHA1_DIGEST_LENGTH);
+ memcpy(ref_update->new_id.hash, iref.new_id, SHA1_DIGEST_LENGTH);
err = got_ref_open(&ref, repo_write.repo, refname, 0);
if (err) {
repo_write.pid);
ref_update->ref = ref;
- if (memcmp(ref_update->new_id.sha1, zero_id, sizeof(zero_id)) == 0) {
+ if (memcmp(ref_update->new_id.hash, zero_id, sizeof(zero_id)) == 0) {
ref_update->delete_ref = 1;
client->nref_del++;
}
}
static const struct got_error *
-recv_packdata(off_t *outsize, uint32_t *nobj, uint8_t *sha1,
+recv_packdata(off_t *outsize, uint32_t *nobj, uint8_t *hash,
int infd, int outfd)
{
const struct got_error *err;
size_t have;
uint32_t nhave = 0;
SHA1_CTX ctx;
- uint8_t expected_sha1[SHA1_DIGEST_LENGTH];
+ uint8_t expected_hash[SHA1_DIGEST_LENGTH];
char hex[SHA1_DIGEST_STRING_LENGTH];
BUF *buf = NULL;
size_t buf_pos = 0, remain;
log_debug("received %u objects", *nobj);
- SHA1Final(expected_sha1, &ctx);
+ SHA1Final(expected_hash, &ctx);
remain = buf_len(buf) - buf_pos;
if (remain < SHA1_DIGEST_LENGTH) {
return err;
}
- got_sha1_digest_to_str(expected_sha1, hex, sizeof(hex));
+ got_sha1_digest_to_str(expected_hash, hex, sizeof(hex));
log_debug("expect SHA1: %s", hex);
got_sha1_digest_to_str(buf_get(buf) + buf_pos, hex, sizeof(hex));
log_debug("actual SHA1: %s", hex);
- if (memcmp(buf_get(buf) + buf_pos, expected_sha1,
+ if (memcmp(buf_get(buf) + buf_pos, expected_hash,
SHA1_DIGEST_LENGTH) != 0) {
err = got_error(GOT_ERR_PACKFILE_CSUM);
goto done;
}
- memcpy(sha1, expected_sha1, SHA1_DIGEST_LENGTH);
+ memcpy(hash, expected_hash, SHA1_DIGEST_LENGTH);
- w = write(outfd, expected_sha1, SHA1_DIGEST_LENGTH);
+ w = write(outfd, expected_hash, SHA1_DIGEST_LENGTH);
if (w == -1) {
err = got_error_from_errno("write");
goto done;
log_debug("receiving pack data");
unpack_err = recv_packdata(&pack_filesize, &nobj,
- client->pack_sha1, client->pack_pipe, pack->fd);
+ client->pack_hash, client->pack_pipe, pack->fd);
if (ireq.report_status) {
err = report_pack_status(unpack_err);
if (err) {
log_debug("begin indexing pack (%lld bytes in size)",
(long long)pack->filesize);
err = got_pack_index(pack, client->packidx_fd,
- tempfiles[0], tempfiles[1], tempfiles[2], client->pack_sha1,
+ tempfiles[0], tempfiles[1], tempfiles[2], client->pack_hash,
pack_index_progress, NULL, &rl);
if (err)
goto done;
memset(&inst, 0, sizeof(inst));
inst.client_id = client->id;
- memcpy(inst.pack_sha1, client->pack_sha1, SHA1_DIGEST_LENGTH);
+ memcpy(inst.pack_hash, client->pack_hash, SHA1_DIGEST_LENGTH);
ret = gotd_imsg_compose_event(iev, GOTD_IMSG_PACKFILE_INSTALL,
PROC_REPO_WRITE, -1, &inst, sizeof(inst));
size_t len;
memset(&iref, 0, sizeof(iref));
- memcpy(iref.old_id, ref_update->old_id.sha1, SHA1_DIGEST_LENGTH);
- memcpy(iref.new_id, ref_update->new_id.sha1, SHA1_DIGEST_LENGTH);
+ memcpy(iref.old_id, ref_update->old_id.hash, SHA1_DIGEST_LENGTH);
+ memcpy(iref.new_id, ref_update->new_id.hash, SHA1_DIGEST_LENGTH);
iref.ref_is_new = ref_update->ref_is_new;
iref.delete_ref = ref_update->delete_ref;
iref.client_id = client->id;
blob - d7e43c48876932a301c2aa803f93172a823359ec
blob + 2fc6c910bb457b3e9579ed53f280815b1e3745ee
--- gotd/session.c
+++ gotd/session.c
return got_error_msg(GOT_ERR_BAD_REQUEST,
"client has no pack file index");
- if (got_sha1_digest_to_str(inst.pack_sha1, hex, sizeof(hex)) == NULL)
+ if (got_sha1_digest_to_str(inst.pack_hash, hex, sizeof(hex)) == NULL)
return got_error_msg(GOT_ERR_NO_SPACE,
"could not convert pack file SHA1 to hex");
if (err)
goto done;
- memcpy(old_id.sha1, iref.old_id, SHA1_DIGEST_LENGTH);
- memcpy(new_id.sha1, iref.new_id, SHA1_DIGEST_LENGTH);
+ memcpy(old_id.hash, iref.old_id, SHA1_DIGEST_LENGTH);
+ memcpy(new_id.hash, iref.new_id, SHA1_DIGEST_LENGTH);
err = got_object_open(&obj, repo,
iref.delete_ref ? &old_id : &new_id);
if (err)
blob - 143943dab41bdfa1c563424971a783ce73ec6ca1
blob + 17dc58ae2833dd6e030301e154782fb31c1a0966
--- lib/deflate.c
+++ lib/deflate.c
if (csum->output_crc)
*csum->output_crc = crc32(*csum->output_crc, buf, len);
- if (csum->output_sha1)
- SHA1Update(csum->output_sha1, buf, len);
+ if (csum->output_hash)
+ SHA1Update(csum->output_hash, buf, len);
}
const struct got_error *
blob - a006844341e6b3ee524360e3929fe3eee0536090
blob + 46b02711be8115b800d930bdce78cdbe0e26c7b5
--- lib/fetch.c
+++ lib/fetch.c
err = got_privsep_recv_fetch_progress(&done,
&id, &refname, symrefs, &server_progress,
- &packfile_size_cur, (*pack_hash)->sha1, &fetchibuf);
+ &packfile_size_cur, (*pack_hash)->hash, &fetchibuf);
if (err != NULL)
goto done;
/* Don't report size progress for an empty pack file. */
err = got_error_from_errno("dup");
goto done;
}
- err = got_privsep_send_index_pack_req(&idxibuf, (*pack_hash)->sha1,
+ err = got_privsep_send_index_pack_req(&idxibuf, (*pack_hash)->hash,
npackfd);
if (err != NULL)
goto done;
blob - 0762e831406c5e0e9f9e6eae03824defa43b6b00
blob + d698a2ced9897b6a0239e0a2db626ce0c5b11b14
--- lib/fileindex.c
+++ lib/fileindex.c
const struct got_error *
got_fileindex_entry_update(struct got_fileindex_entry *ie,
- int wt_fd, const char *ondisk_path, uint8_t *blob_sha1,
- uint8_t *commit_sha1, int update_timestamps)
+ int wt_fd, const char *ondisk_path, uint8_t *blob_hash,
+ uint8_t *commit_hash, int update_timestamps)
{
struct stat sb;
}
}
- if (blob_sha1) {
- memcpy(ie->blob_sha1, blob_sha1, SHA1_DIGEST_LENGTH);
+ if (blob_hash) {
+ memcpy(ie->blob_hash, blob_hash, SHA1_DIGEST_LENGTH);
ie->flags &= ~GOT_FILEIDX_F_NO_BLOB;
} else
ie->flags |= GOT_FILEIDX_F_NO_BLOB;
- if (commit_sha1) {
- memcpy(ie->commit_sha1, commit_sha1, SHA1_DIGEST_LENGTH);
+ if (commit_hash) {
+ memcpy(ie->commit_hash, commit_hash, SHA1_DIGEST_LENGTH);
ie->flags &= ~GOT_FILEIDX_F_NO_COMMIT;
} else
ie->flags |= GOT_FILEIDX_F_NO_COMMIT;
if (err)
return err;
- SHA1Update(ctx, ie->blob_sha1, SHA1_DIGEST_LENGTH);
- n = fwrite(ie->blob_sha1, 1, SHA1_DIGEST_LENGTH, outfile);
+ SHA1Update(ctx, ie->blob_hash, SHA1_DIGEST_LENGTH);
+ n = fwrite(ie->blob_hash, 1, SHA1_DIGEST_LENGTH, outfile);
if (n != SHA1_DIGEST_LENGTH)
return got_ferror(outfile, GOT_ERR_IO);
- SHA1Update(ctx, ie->commit_sha1, SHA1_DIGEST_LENGTH);
- n = fwrite(ie->commit_sha1, 1, SHA1_DIGEST_LENGTH, outfile);
+ SHA1Update(ctx, ie->commit_hash, SHA1_DIGEST_LENGTH);
+ n = fwrite(ie->commit_hash, 1, SHA1_DIGEST_LENGTH, outfile);
if (n != SHA1_DIGEST_LENGTH)
return got_ferror(outfile, GOT_ERR_IO);
stage = got_fileindex_entry_stage_get(ie);
if (stage == GOT_FILEIDX_STAGE_MODIFY ||
stage == GOT_FILEIDX_STAGE_ADD) {
- SHA1Update(ctx, ie->staged_blob_sha1, SHA1_DIGEST_LENGTH);
- n = fwrite(ie->staged_blob_sha1, 1, SHA1_DIGEST_LENGTH,
+ SHA1Update(ctx, ie->staged_blob_hash, SHA1_DIGEST_LENGTH);
+ n = fwrite(ie->staged_blob_hash, 1, SHA1_DIGEST_LENGTH,
outfile);
if (n != SHA1_DIGEST_LENGTH)
return got_ferror(outfile, GOT_ERR_IO);
const struct got_error *err = NULL;
struct got_fileindex_hdr hdr;
SHA1_CTX ctx;
- uint8_t sha1[SHA1_DIGEST_LENGTH];
+ uint8_t hash[SHA1_DIGEST_LENGTH];
size_t n;
struct got_fileindex_entry *ie, *tmp;
return err;
}
- SHA1Final(sha1, &ctx);
- n = fwrite(sha1, 1, sizeof(sha1), outfile);
- if (n != sizeof(sha1))
+ SHA1Final(hash, &ctx);
+ n = fwrite(hash, 1, sizeof(hash), outfile);
+ if (n != sizeof(hash))
return got_ferror(outfile, GOT_ERR_IO);
if (fflush(outfile) != 0)
if (err)
goto done;
- n = fread(ie->blob_sha1, 1, SHA1_DIGEST_LENGTH, infile);
+ n = fread(ie->blob_hash, 1, SHA1_DIGEST_LENGTH, infile);
if (n != SHA1_DIGEST_LENGTH) {
err = got_ferror(infile, GOT_ERR_FILEIDX_BAD);
goto done;
}
- SHA1Update(ctx, ie->blob_sha1, SHA1_DIGEST_LENGTH);
+ SHA1Update(ctx, ie->blob_hash, SHA1_DIGEST_LENGTH);
- n = fread(ie->commit_sha1, 1, SHA1_DIGEST_LENGTH, infile);
+ n = fread(ie->commit_hash, 1, SHA1_DIGEST_LENGTH, infile);
if (n != SHA1_DIGEST_LENGTH) {
err = got_ferror(infile, GOT_ERR_FILEIDX_BAD);
goto done;
}
- SHA1Update(ctx, ie->commit_sha1, SHA1_DIGEST_LENGTH);
+ SHA1Update(ctx, ie->commit_hash, SHA1_DIGEST_LENGTH);
err = read_fileindex_val32(&ie->flags, ctx, infile);
if (err)
uint32_t stage = got_fileindex_entry_stage_get(ie);
if (stage == GOT_FILEIDX_STAGE_MODIFY ||
stage == GOT_FILEIDX_STAGE_ADD) {
- n = fread(ie->staged_blob_sha1, 1, SHA1_DIGEST_LENGTH,
+ n = fread(ie->staged_blob_hash, 1, SHA1_DIGEST_LENGTH,
infile);
if (n != SHA1_DIGEST_LENGTH) {
err = got_ferror(infile, GOT_ERR_FILEIDX_BAD);
goto done;
}
- SHA1Update(ctx, ie->staged_blob_sha1, SHA1_DIGEST_LENGTH);
+ SHA1Update(ctx, ie->staged_blob_hash, SHA1_DIGEST_LENGTH);
}
} else {
/* GOT_FILE_INDEX_VERSION 1 does not support staging. */
struct got_fileindex_hdr hdr;
SHA1_CTX ctx;
struct got_fileindex_entry *ie;
- uint8_t sha1_expected[SHA1_DIGEST_LENGTH];
- uint8_t sha1[SHA1_DIGEST_LENGTH];
+ uint8_t hash_expected[SHA1_DIGEST_LENGTH];
+ uint8_t hash[SHA1_DIGEST_LENGTH];
size_t n;
int i;
return err;
}
- n = fread(sha1_expected, 1, sizeof(sha1_expected), infile);
- if (n != sizeof(sha1_expected))
+ n = fread(hash_expected, 1, sizeof(hash_expected), infile);
+ if (n != sizeof(hash_expected))
return got_ferror(infile, GOT_ERR_FILEIDX_BAD);
- SHA1Final(sha1, &ctx);
- if (memcmp(sha1, sha1_expected, SHA1_DIGEST_LENGTH) != 0)
+ SHA1Final(hash, &ctx);
+ if (memcmp(hash, hash_expected, SHA1_DIGEST_LENGTH) != 0)
return got_error(GOT_ERR_FILEIDX_CSUM);
return NULL;
blob - 2575eb63d3f9bfe0cd35903ae30824124fa07ca8
blob + b7e5f1db5b6082c9d5b868be5712c8993c3689c3
--- lib/got_lib_deflate.h
+++ lib/got_lib_deflate.h
uint32_t *output_crc;
/* If not NULL, mix output bytes into this SHA1 context. */
- SHA1_CTX *output_sha1;
+ SHA1_CTX *output_hash;
};
struct got_deflate_buf {
blob - 0c22385de5665de7e4366e6db2b42d3737058e0f
blob + 6156c4d96c3ccb15cf30ce5f7236ae09586a6299
--- lib/got_lib_fileindex.h
+++ lib/got_lib_fileindex.h
#define GOT_FILEIDX_MODE_PERMS_SHIFT 4
/* SHA1 of corresponding blob in repository. */
- uint8_t blob_sha1[SHA1_DIGEST_LENGTH];
+ uint8_t blob_hash[SHA1_DIGEST_LENGTH];
/* SHA1 of corresponding base commit in repository. */
- uint8_t commit_sha1[SHA1_DIGEST_LENGTH];
+ uint8_t commit_hash[SHA1_DIGEST_LENGTH];
uint32_t flags;
* GOT_FILEIDX_STAGE_MODIFY or GOT_FILEIDX_STAGE_ADD.
* Otherwise, this field is not written to disk.
*/
- uint8_t staged_blob_sha1[SHA1_DIGEST_LENGTH];
+ uint8_t staged_blob_hash[SHA1_DIGEST_LENGTH];
};
/* Modifications explicitly staged for commit. */
#define GOT_FILE_INDEX_VERSION 2
uint32_t nentries; /* big-endian */
/* list of concatenated fileindex entries */
- uint8_t sha1[SHA1_DIGEST_LENGTH]; /* checksum of above on-disk data */
+ uint8_t hash[SHA1_DIGEST_LENGTH]; /* checksum of above on-disk data */
};
mode_t got_fileindex_entry_perms_get(struct got_fileindex_entry *);
blob - 4ddc5aac63e46a5562147f8b561c4dea76cad65c
blob + 276955ef59f1f876bd0d16fd0ae8c624cbb843c0
--- lib/got_lib_inflate.h
+++ lib/got_lib_inflate.h
uint32_t *input_crc;
/* If not NULL, mix input bytes into this SHA1 context. */
- SHA1_CTX *input_sha1;
+ SHA1_CTX *input_hash;
/* If not NULL, mix output bytes into this CRC checksum. */
uint32_t *output_crc;
/* If not NULL, mix output bytes into this SHA1 context. */
- SHA1_CTX *output_sha1;
+ SHA1_CTX *output_hash;
};
struct got_inflate_buf {
blob - 188c28e9e67bdc37146176e911d6226b223c40d2
blob + 3ca37674822674c80444158b4083d669c36da1d3
--- lib/got_lib_pack.h
+++ lib/got_lib_pack.h
/* See Documentation/technical/pack-format.txt in Git. */
struct got_packidx_trailer {
- u_int8_t packfile_sha1[SHA1_DIGEST_LENGTH];
- u_int8_t packidx_sha1[SHA1_DIGEST_LENGTH];
+ u_int8_t packfile_hash[SHA1_DIGEST_LENGTH];
+ u_int8_t packidx_hash[SHA1_DIGEST_LENGTH];
} __attribute__((__packed__));
struct got_packidx_object_id {
- u_int8_t sha1[SHA1_DIGEST_LENGTH];
+ u_int8_t hash[SHA1_DIGEST_LENGTH];
} __attribute__((__packed__));
/* Ignore pack index version 1 which is no longer written by Git. */
/* If object is of type GOT_OBJ_TYPE_REF_DELTA. */
struct got_packfile_object_data_ref_delta {
- uint8_t sha1[SHA1_DIGEST_LENGTH];
+ uint8_t hash[SHA1_DIGEST_LENGTH];
uint8_t *delta_data; /* compressed */
};
blob - 7a3c6579c0c3c5ab813f5c5cdb1093a791ac08b4
blob + 11b6bffac63b1961d377105074c25ae65a3c23c2
--- lib/got_lib_pack_create.h
+++ lib/got_lib_pack_create.h
* Write pack file data into the provided open packfile handle, for all
* objects reachable via the commits listed in 'ours'.
* Exclude any objects for commits listed in 'theirs' if 'theirs' is not NULL.
- * Return the SHA1 digest of the resulting pack file in pack_sha1 which must
+ * Return the SHA1 digest of the resulting pack file in pack_hash which must
* be pre-allocated by the caller with at least SHA1_DIGEST_LENGTH bytes.
*/
-const struct got_error *got_pack_create(uint8_t *pack_sha1, int packfd,
+const struct got_error *got_pack_create(uint8_t *pack_hash, int packfd,
FILE *delta_cache, struct got_object_id **theirs, int ntheirs,
struct got_object_id **ours, int nours,
struct got_repository *repo, int loose_obj_only, int allow_empty,
blob - bec94759fda7eb63db8c6a38520291cd5c1a8ad1
blob + f5f3787f6b9ced9b93f822891e4f84591d8faab5
--- lib/got_lib_pack_index.h
+++ lib/got_lib_pack_index.h
const struct got_error *
got_pack_index(struct got_pack *pack, int idxfd,
FILE *tmpfile, FILE *delta_base_file, FILE *delta_accum_file,
- uint8_t *pack_sha1_expected,
+ uint8_t *pack_hash_expected,
got_pack_index_progress_cb progress_cb, void *progress_arg,
struct got_ratelimit *rl);
blob - dc46eb047636a6ef075d902f58565030b486aa27
blob + 33354fbde43d41ee05a858a41337eaeba1639acb
--- lib/inflate.c
+++ lib/inflate.c
if (csum->input_crc)
*csum->input_crc = crc32(*csum->input_crc, buf, len);
- if (csum->input_sha1)
- SHA1Update(csum->input_sha1, buf, len);
+ if (csum->input_hash)
+ SHA1Update(csum->input_hash, buf, len);
}
static void
if (csum->output_crc)
*csum->output_crc = crc32(*csum->output_crc, buf, len);
- if (csum->output_sha1)
- SHA1Update(csum->output_sha1, buf, len);
+ if (csum->output_hash)
+ SHA1Update(csum->output_hash, buf, len);
}
const struct got_error *
blob - 57876d8fb763d7736c0cb4fbb6967718793d2cea
blob + 87add3cc522abd473e4ce6fc913540428ddc058b
--- lib/object.c
+++ lib/object.c
goto done;
if (asprintf(path, "%s/%.2x/%s", path_objects,
- id->sha1[0], hex + 2) == -1)
+ id->hash[0], hex + 2) == -1)
err = got_error_from_errno("asprintf");
done:
{
struct got_object_id id;
- if (!got_parse_sha1_digest(id.sha1, id_str))
+ if (!got_parse_sha1_digest(id.hash, id_str))
return got_error_path(id_str, GOT_ERR_BAD_OBJ_ID_STR);
return got_object_open(obj, repo, &id);
blob - 8fa42a873d1dd3feb591275a17e1bd546c3dab59
blob + 602a0299443f4ab08a46d042143e10f8b8d2bba2
--- lib/object_create.c
+++ lib/object_create.c
char *header = NULL;
int fd = -1;
struct stat sb;
- SHA1_CTX sha1_ctx;
+ SHA1_CTX hash_ctx;
size_t headerlen = 0, n;
*id = NULL;
*blobfile = NULL;
*blobsize = 0;
- SHA1Init(&sha1_ctx);
+ SHA1Init(&hash_ctx);
fd = open(ondisk_path, O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
if (fd == -1) {
goto done;
}
headerlen = strlen(header) + 1;
- SHA1Update(&sha1_ctx, header, headerlen);
+ SHA1Update(&hash_ctx, header, headerlen);
*blobfile = got_opentemp();
if (*blobfile == NULL) {
}
if (inlen == 0)
break; /* EOF */
- SHA1Update(&sha1_ctx, buf, inlen);
+ SHA1Update(&hash_ctx, buf, inlen);
n = fwrite(buf, 1, inlen, *blobfile);
if (n != inlen) {
err = got_ferror(*blobfile, GOT_ERR_IO);
err = got_error_from_errno("malloc");
goto done;
}
- SHA1Final((*id)->sha1, &sha1_ctx);
+ SHA1Final((*id)->hash, &hash_ctx);
if (fflush(*blobfile) != 0) {
err = got_error_from_errno("fflush");
{
const struct got_error *err = NULL;
char modebuf[sizeof("100644 ")];
- SHA1_CTX sha1_ctx;
+ SHA1_CTX hash_ctx;
char *header = NULL;
size_t headerlen, len = 0, n;
FILE *treefile = NULL;
*id = NULL;
- SHA1Init(&sha1_ctx);
+ SHA1Init(&hash_ctx);
sorted_entries = calloc(nentries, sizeof(struct got_tree_entry *));
if (sorted_entries == NULL)
goto done;
}
headerlen = strlen(header) + 1;
- SHA1Update(&sha1_ctx, header, headerlen);
+ SHA1Update(&hash_ctx, header, headerlen);
treefile = got_opentemp();
if (treefile == NULL) {
err = got_ferror(treefile, GOT_ERR_IO);
goto done;
}
- SHA1Update(&sha1_ctx, modebuf, len);
+ SHA1Update(&hash_ctx, modebuf, len);
treesize += n;
len = strlen(te->name) + 1; /* must include NUL */
err = got_ferror(treefile, GOT_ERR_IO);
goto done;
}
- SHA1Update(&sha1_ctx, te->name, len);
+ SHA1Update(&hash_ctx, te->name, len);
treesize += n;
len = SHA1_DIGEST_LENGTH;
- n = fwrite(te->id.sha1, 1, len, treefile);
+ n = fwrite(te->id.hash, 1, len, treefile);
if (n != len) {
err = got_ferror(treefile, GOT_ERR_IO);
goto done;
}
- SHA1Update(&sha1_ctx, te->id.sha1, len);
+ SHA1Update(&hash_ctx, te->id.hash, len);
treesize += n;
}
err = got_error_from_errno("malloc");
goto done;
}
- SHA1Final((*id)->sha1, &sha1_ctx);
+ SHA1Final((*id)->hash, &hash_ctx);
if (fflush(treefile) != 0) {
err = got_error_from_errno("fflush");
const char *logmsg, struct got_repository *repo)
{
const struct got_error *err = NULL;
- SHA1_CTX sha1_ctx;
+ SHA1_CTX hash_ctx;
char *header = NULL, *tree_str = NULL;
char *author_str = NULL, *committer_str = NULL;
char *id_str = NULL;
*id = NULL;
- SHA1Init(&sha1_ctx);
+ SHA1Init(&hash_ctx);
msg0 = strdup(logmsg);
if (msg0 == NULL)
goto done;
}
headerlen = strlen(header) + 1;
- SHA1Update(&sha1_ctx, header, headerlen);
+ SHA1Update(&hash_ctx, header, headerlen);
commitfile = got_opentemp();
if (commitfile == NULL) {
goto done;
}
len = strlen(tree_str);
- SHA1Update(&sha1_ctx, tree_str, len);
+ SHA1Update(&hash_ctx, tree_str, len);
n = fwrite(tree_str, 1, len, commitfile);
if (n != len) {
err = got_ferror(commitfile, GOT_ERR_IO);
goto done;
}
len = strlen(parent_str);
- SHA1Update(&sha1_ctx, parent_str, len);
+ SHA1Update(&hash_ctx, parent_str, len);
n = fwrite(parent_str, 1, len, commitfile);
if (n != len) {
err = got_ferror(commitfile, GOT_ERR_IO);
}
len = strlen(author_str);
- SHA1Update(&sha1_ctx, author_str, len);
+ SHA1Update(&hash_ctx, author_str, len);
n = fwrite(author_str, 1, len, commitfile);
if (n != len) {
err = got_ferror(commitfile, GOT_ERR_IO);
commitsize += n;
len = strlen(committer_str);
- SHA1Update(&sha1_ctx, committer_str, len);
+ SHA1Update(&hash_ctx, committer_str, len);
n = fwrite(committer_str, 1, len, commitfile);
if (n != len) {
err = got_ferror(commitfile, GOT_ERR_IO);
}
commitsize += n;
- SHA1Update(&sha1_ctx, "\n", 1);
+ SHA1Update(&hash_ctx, "\n", 1);
n = fwrite("\n", 1, 1, commitfile);
if (n != 1) {
err = got_ferror(commitfile, GOT_ERR_IO);
commitsize += n;
len = strlen(msg);
- SHA1Update(&sha1_ctx, msg, len);
+ SHA1Update(&hash_ctx, msg, len);
n = fwrite(msg, 1, len, commitfile);
if (n != len) {
err = got_ferror(commitfile, GOT_ERR_IO);
}
commitsize += n;
- SHA1Update(&sha1_ctx, "\n", 1);
+ SHA1Update(&hash_ctx, "\n", 1);
n = fwrite("\n", 1, 1, commitfile);
if (n != 1) {
err = got_ferror(commitfile, GOT_ERR_IO);
err = got_error_from_errno("malloc");
goto done;
}
- SHA1Final((*id)->sha1, &sha1_ctx);
+ SHA1Final((*id)->hash, &hash_ctx);
if (fflush(commitfile) != 0) {
err = got_error_from_errno("fflush");
struct got_repository *repo, int verbosity)
{
const struct got_error *err = NULL;
- SHA1_CTX sha1_ctx;
+ SHA1_CTX hash_ctx;
char *header = NULL;
char *tag_str = NULL, *tagger_str = NULL;
char *id_str = NULL, *obj_str = NULL, *type_str = NULL;
*id = NULL;
- SHA1Init(&sha1_ctx);
+ SHA1Init(&hash_ctx);
err = got_object_id_str(&id_str, object_id);
if (err)
}
headerlen = strlen(header) + 1;
- SHA1Update(&sha1_ctx, header, headerlen);
+ SHA1Update(&hash_ctx, header, headerlen);
tagfile = got_opentemp();
if (tagfile == NULL) {
}
tagsize += headerlen;
len = strlen(obj_str);
- SHA1Update(&sha1_ctx, obj_str, len);
+ SHA1Update(&hash_ctx, obj_str, len);
n = fwrite(obj_str, 1, len, tagfile);
if (n != len) {
err = got_ferror(tagfile, GOT_ERR_IO);
}
tagsize += n;
len = strlen(type_str);
- SHA1Update(&sha1_ctx, type_str, len);
+ SHA1Update(&hash_ctx, type_str, len);
n = fwrite(type_str, 1, len, tagfile);
if (n != len) {
err = got_ferror(tagfile, GOT_ERR_IO);
tagsize += n;
len = strlen(tag_str);
- SHA1Update(&sha1_ctx, tag_str, len);
+ SHA1Update(&hash_ctx, tag_str, len);
n = fwrite(tag_str, 1, len, tagfile);
if (n != len) {
err = got_ferror(tagfile, GOT_ERR_IO);
tagsize += n;
len = strlen(tagger_str);
- SHA1Update(&sha1_ctx, tagger_str, len);
+ SHA1Update(&hash_ctx, tagger_str, len);
n = fwrite(tagger_str, 1, len, tagfile);
if (n != len) {
err = got_ferror(tagfile, GOT_ERR_IO);
}
tagsize += n;
- SHA1Update(&sha1_ctx, "\n", 1);
+ SHA1Update(&hash_ctx, "\n", 1);
n = fwrite("\n", 1, 1, tagfile);
if (n != 1) {
err = got_ferror(tagfile, GOT_ERR_IO);
tagsize += n;
len = strlen(msg);
- SHA1Update(&sha1_ctx, msg, len);
+ SHA1Update(&hash_ctx, msg, len);
n = fwrite(msg, 1, len, tagfile);
if (n != len) {
err = got_ferror(tagfile, GOT_ERR_IO);
}
tagsize += n;
- SHA1Update(&sha1_ctx, "\n", 1);
+ SHA1Update(&hash_ctx, "\n", 1);
n = fwrite("\n", 1, 1, tagfile);
if (n != 1) {
err = got_ferror(tagfile, GOT_ERR_IO);
if (signer_id && buf_len(buf) > 0) {
len = buf_len(buf);
- SHA1Update(&sha1_ctx, buf_get(buf), len);
+ SHA1Update(&hash_ctx, buf_get(buf), len);
n = fwrite(buf_get(buf), 1, len, tagfile);
if (n != len) {
err = got_ferror(tagfile, GOT_ERR_IO);
err = got_error_from_errno("malloc");
goto done;
}
- SHA1Final((*id)->sha1, &sha1_ctx);
+ SHA1Final((*id)->hash, &hash_ctx);
if (fflush(tagfile) != 0) {
err = got_error_from_errno("fflush");
blob - f58d1e7dc1d81be2989c4b8114725ca657c9ea3a
blob + 3a2d5a962ea374806ad2b70a660d0466c38b7615
--- lib/object_idset.c
+++ lib/object_idset.c
static uint64_t
idset_hash(struct got_object_idset *set, struct got_object_id *id)
{
- return SipHash24(&set->key, id->sha1, sizeof(id->sha1));
+ return SipHash24(&set->key, id->hash, sizeof(id->hash));
}
static const struct got_error *
blob - 40afcdfffec70644278cf7d34e73724d4932e5ff
blob + ad79d81bee4c8f522e0068cf04aba9e4638c7fe3
--- lib/object_open_io.c
+++ lib/object_open_io.c
err = got_error(GOT_ERR_NO_SPACE);
goto done;
}
- memcpy(te->id.sha1, pe->id, SHA1_DIGEST_LENGTH);
+ memcpy(te->id.hash, pe->id, SHA1_DIGEST_LENGTH);
te->mode = pe->mode;
te->idx = i;
}
blob - f80d86a8686711ff5888dd6847e0d84b98bc0672
blob + 9da64da69ffd4bc3a2b912a49a0eb2b9e2bb175d
--- lib/object_open_privsep.c
+++ lib/object_open_privsep.c
if (err)
return err;
- memcpy((*obj)->id.sha1, id->sha1, SHA1_DIGEST_LENGTH);
+ memcpy((*obj)->id.hash, id->hash, SHA1_DIGEST_LENGTH);
(*obj)->refcnt++;
return got_repo_cache_object(repo, id, *obj);
(*blob)->hdrlen = hdrlen;
(*blob)->blocksize = blocksize;
- memcpy(&(*blob)->id.sha1, id->sha1, SHA1_DIGEST_LENGTH);
+ memcpy(&(*blob)->id.hash, id->hash, SHA1_DIGEST_LENGTH);
done:
free(path_packfile);
blob - 52fd48d81fd6b40f63ea1b5b40edbb3c8e40b3a2
blob + 41cc314e9780dbbce0599c51f52b164003522497
--- lib/object_parse.c
+++ lib/object_parse.c
got_object_id_cmp(const struct got_object_id *id1,
const struct got_object_id *id2)
{
- return memcmp(id1->sha1, id2->sha1, SHA1_DIGEST_LENGTH);
+ return memcmp(id1->hash, id2->hash, SHA1_DIGEST_LENGTH);
}
const struct got_error *
}
SHA1Final(sha1, &sha1_ctx);
- if (memcmp(expected_id->sha1, sha1, SHA1_DIGEST_LENGTH) != 0) {
+ if (memcmp(expected_id->hash, sha1, SHA1_DIGEST_LENGTH) != 0) {
err = got_error_checksum(expected_id);
goto done;
}
if (err)
return err;
- if (!got_parse_sha1_digest(qid->id.sha1, id_str)) {
+ if (!got_parse_sha1_digest(qid->id.hash, id_str)) {
err = got_error(GOT_ERR_BAD_OBJ_DATA);
got_object_qid_free(qid);
return err;
goto done;
}
s += label_len;
- if (!got_parse_sha1_digest((*commit)->tree_id->sha1, s)) {
+ if (!got_parse_sha1_digest((*commit)->tree_id->hash, s)) {
err = got_error(GOT_ERR_BAD_OBJ_DATA);
goto done;
}
SHA1_CTX sha1_ctx;
struct got_object_id id;
- SHA1Init(&sha1_ctx);
+ SHA1Init(&hash_ctx);
memset(&csum, 0, sizeof(csum));
- csum.output_sha1 = &sha1_ctx;
+ csum.output_hash = &hash_ctx;
err = got_inflate_to_mem_fd(&p, &len, NULL, &csum, expected_size, fd);
if (err)
return err;
- SHA1Final(id.sha1, &sha1_ctx);
+ SHA1Final(id.hash, &sha1_ctx);
if (got_object_id_cmp(expected_id, &id) != 0) {
err = got_error_checksum(expected_id);
goto done;
if (err)
return err;
- SHA1Final(id.sha1, &sha1_ctx);
+ SHA1Final(id.hash, &sha1_ctx);
if (got_object_id_cmp(expected_id, &id) != 0) {
err = got_error_checksum(expected_id);
goto done;
goto done;
}
s += label_len;
- if (!got_parse_sha1_digest((*tag)->id.sha1, s)) {
+ if (!got_parse_sha1_digest((*tag)->id.hash, s)) {
err = got_error(GOT_ERR_BAD_OBJ_DATA);
goto done;
}
if (err)
return err;
- SHA1Final(id.sha1, &sha1_ctx);
+ SHA1Final(id.hash, &sha1_ctx);
if (got_object_id_cmp(expected_id, &id) != 0) {
err = got_error_checksum(expected_id);
goto done;
blob - 68de5bf9f8523cf07c88e05955ce9b4c6abc451a
blob + 25dd12c77e6cfd60bf31d8234c00ce4e4827b99c
--- lib/pack.c
+++ lib/pack.c
const struct got_error *err = NULL;
struct got_packidx_v2_hdr *h;
SHA1_CTX ctx;
- uint8_t sha1[SHA1_DIGEST_LENGTH];
+ uint8_t hash[SHA1_DIGEST_LENGTH];
size_t nobj, len_fanout, len_ids, offset, remain;
ssize_t n;
int i;
}
}
if (verify) {
- SHA1Update(&ctx, h->trailer->packfile_sha1, SHA1_DIGEST_LENGTH);
- SHA1Final(sha1, &ctx);
- if (memcmp(h->trailer->packidx_sha1, sha1,
+ SHA1Update(&ctx, h->trailer->packfile_hash, SHA1_DIGEST_LENGTH);
+ SHA1Final(hash, &ctx);
+ if (memcmp(h->trailer->packidx_hash, hash,
SHA1_DIGEST_LENGTH) != 0)
err = got_error(GOT_ERR_PACKIDX_CSUM);
}
got_packidx_get_object_idx(struct got_packidx *packidx,
struct got_object_id *id)
{
- u_int8_t id0 = id->sha1[0];
+ u_int8_t id0 = id->hash[0];
uint32_t totobj = be32toh(packidx->hdr.fanout_table[0xff]);
int left = 0, right = totobj - 1;
i = ((left + right) / 2);
oid = &packidx->hdr.sorted_ids[i];
- cmp = memcmp(id->sha1, oid->sha1, SHA1_DIGEST_LENGTH);
+ cmp = memcmp(id->hash, oid->hash, SHA1_DIGEST_LENGTH);
if (cmp == 0)
return i;
else if (cmp > 0)
return got_error(GOT_ERR_NO_OBJ);
oid = &packidx->hdr.sorted_ids[idx];
- memcpy(id->sha1, oid->sha1, SHA1_DIGEST_LENGTH);
+ memcpy(id->hash, oid->hash, SHA1_DIGEST_LENGTH);
return NULL;
}
if (id0 > 0)
i = be32toh(packidx->hdr.fanout_table[id0 - 1]);
oid = &packidx->hdr.sorted_ids[i];
- while (i < totobj && oid->sha1[0] == id0) {
+ while (i < totobj && oid->hash[0] == id0) {
char id_str[SHA1_DIGEST_STRING_LENGTH];
struct got_object_qid *qid;
int cmp;
- if (!got_sha1_digest_to_str(oid->sha1, id_str, sizeof(id_str)))
+ if (!got_sha1_digest_to_str(oid->hash, id_str, sizeof(id_str)))
return got_error(GOT_ERR_NO_SPACE);
cmp = strncmp(id_str, id_str_prefix, prefix_len);
err = got_object_qid_alloc_partial(&qid);
if (err)
break;
- memcpy(qid->id.sha1, oid->sha1, SHA1_DIGEST_LENGTH);
+ memcpy(qid->id.hash, oid->hash, SHA1_DIGEST_LENGTH);
STAILQ_INSERT_TAIL(matched_ids, qid, entry);
oid = &packidx->hdr.sorted_ids[++i];
blob - 0dda4f95f2b3f8b16523c768cd55fa04de120f90
blob + 54824509617d31f3a5ee2c6a5c913b0776f7945f
--- lib/pack_create.c
+++ lib/pack_create.c
if (err)
return err;
*packfile_size += nh;
- err = hwrite(packfd, m->prev->id.sha1,
- sizeof(m->prev->id.sha1), ctx);
+ err = hwrite(packfd, m->prev->id.hash,
+ sizeof(m->prev->id.hash), ctx);
if (err)
return err;
- *packfile_size += sizeof(m->prev->id.sha1);
+ *packfile_size += sizeof(m->prev->id.hash);
}
return NULL;
struct got_raw_object *raw = NULL;
off_t outlen, delta_offset;
- csum.output_sha1 = ctx;
+ csum.output_hash = ctx;
csum.output_crc = NULL;
if (m->reused_delta_offset)
}
static const struct got_error *
-genpack(uint8_t *pack_sha1, int packfd, struct got_pack *reuse_pack,
+genpack(uint8_t *pack_hash, int packfd, struct got_pack *reuse_pack,
FILE *delta_cache, struct got_pack_meta **deltify, int ndeltify,
struct got_pack_meta **reuse, int nreuse,
int ncolored, int nfound, int ntrees, int nours,
goto done;
}
- SHA1Final(pack_sha1, &ctx);
- err = got_poll_write_full(packfd, pack_sha1, SHA1_DIGEST_LENGTH);
+ SHA1Final(pack_hash, &ctx);
+ err = got_poll_write_full(packfd, pack_hash, SHA1_DIGEST_LENGTH);
if (err)
goto done;
packfile_size += SHA1_DIGEST_LENGTH;
}
const struct got_error *
-got_pack_create(uint8_t *packsha1, int packfd, FILE *delta_cache,
+got_pack_create(uint8_t *packhash, int packfd, FILE *delta_cache,
struct got_object_id **theirs, int ntheirs,
struct got_object_id **ours, int nours,
struct got_repository *repo, int loose_obj_only, int allow_empty,
goto done;
}
- err = genpack(packsha1, packfd, reuse_pack, delta_cache, deltify.meta,
+ err = genpack(packhash, packfd, reuse_pack, delta_cache, deltify.meta,
deltify.nmeta, reuse.meta, reuse.nmeta, ncolored, nfound, ntrees,
nours, repo, progress_cb, progress_arg, rl,
cancel_cb, cancel_arg);
blob - dbd1daa943f326573aefc06b1316d88bee4e852a
blob + 8ce03734c547cced2d00a7dca6105b30107b8f27
--- lib/pack_index.c
+++ lib/pack_index.c
}
static const struct got_error *
-read_checksum(uint32_t *crc, SHA1_CTX *sha1_ctx, int fd, size_t len)
+read_checksum(uint32_t *crc, SHA1_CTX *hash_ctx, int fd, size_t len)
{
uint8_t buf[8192];
size_t n;
break;
if (crc)
*crc = crc32(*crc, buf, r);
- if (sha1_ctx)
- SHA1Update(sha1_ctx, buf, r);
+ if (hash_ctx)
+ SHA1Update(hash_ctx, buf, r);
}
return NULL;
}
static const struct got_error *
-read_file_sha1(SHA1_CTX *ctx, FILE *f, size_t len)
+read_file_hash(SHA1_CTX *ctx, FILE *f, size_t len)
{
uint8_t buf[8192];
size_t n, r;
headerlen = strlen(header) + 1;
SHA1Update(&ctx, header, headerlen);
if (obj->size > GOT_DELTA_RESULT_SIZE_CACHED_MAX) {
- err = read_file_sha1(&ctx, tmpfile, datalen);
+ err = read_file_hash(&ctx, tmpfile, datalen);
if (err) {
free(header);
free(data);
}
} else
SHA1Update(&ctx, data, datalen);
- SHA1Final(obj->id.sha1, &ctx);
+ SHA1Final(obj->id.hash, &ctx);
free(header);
free(data);
break;
case GOT_OBJ_TYPE_REF_DELTA:
- memset(obj->id.sha1, 0xff, SHA1_DIGEST_LENGTH);
+ memset(obj->id.hash, 0xff, SHA1_DIGEST_LENGTH);
if (pack->map) {
if (mapoff + SHA1_DIGEST_LENGTH >= pack->filesize) {
err = got_error(GOT_ERR_BAD_PACKFILE);
(long long)mapoff + SHA1_DIGEST_LENGTH);
break;
}
- memcpy(obj->delta.ref.ref_id.sha1, pack->map + mapoff,
+ memcpy(obj->delta.ref.ref_id.hash, pack->map + mapoff,
SHA1_DIGEST_LENGTH);
obj->crc = crc32(obj->crc, pack->map + mapoff,
SHA1_DIGEST_LENGTH);
if (err)
break;
} else {
- n = read(pack->fd, obj->delta.ref.ref_id.sha1,
+ n = read(pack->fd, obj->delta.ref.ref_id.hash,
SHA1_DIGEST_LENGTH);
if (n == -1) {
err = got_error_from_errno("read");
err = got_error(GOT_ERR_BAD_PACKFILE);
break;
}
- obj->crc = crc32(obj->crc, obj->delta.ref.ref_id.sha1,
+ obj->crc = crc32(obj->crc, obj->delta.ref.ref_id.hash,
SHA1_DIGEST_LENGTH);
- SHA1Update(pack_sha1_ctx, obj->delta.ref.ref_id.sha1,
+ SHA1Update(pack_sha1_ctx, obj->delta.ref.ref_id.hash,
SHA1_DIGEST_LENGTH);
err = got_inflate_to_mem_fd(NULL, &datalen, &obj->len,
&csum, obj->size, pack->fd);
obj->len += SHA1_DIGEST_LENGTH;
break;
case GOT_OBJ_TYPE_OFFSET_DELTA:
- memset(obj->id.sha1, 0xff, SHA1_DIGEST_LENGTH);
+ memset(obj->id.hash, 0xff, SHA1_DIGEST_LENGTH);
err = got_pack_parse_offset_delta(&obj->delta.ofs.base_offset,
&obj->delta.ofs.base_offsetlen, pack, obj->off,
obj->tslen);
SHA1Init(&ctx);
SHA1Update(&ctx, header, headerlen);
if (max_size > GOT_DELTA_RESULT_SIZE_CACHED_MAX) {
- err = read_file_sha1(&ctx, tmpfile, len);
+ err = read_file_hash(&ctx, tmpfile, len);
if (err)
goto done;
} else
SHA1Update(&ctx, buf, len);
- SHA1Final(obj->id.sha1, &ctx);
+ SHA1Final(obj->id.hash, &ctx);
done:
free(buf);
free(header);
/* Determine the slot in the pack index a given object ID should use. */
static int
-find_object_idx(struct got_packidx *packidx, uint8_t *sha1)
+find_object_idx(struct got_packidx *packidx, uint8_t *hash)
{
- u_int8_t id0 = sha1[0];
+ u_int8_t id0 = hash[0];
uint32_t nindexed = be32toh(packidx->hdr.fanout_table[0xff]);
int left = 0, right = nindexed - 1;
int cmp = 0, i = 0;
i = ((left + right) / 2);
oid = &packidx->hdr.sorted_ids[i];
- cmp = memcmp(sha1, oid->sha1, SHA1_DIGEST_LENGTH);
+ cmp = memcmp(hash, oid->hash, SHA1_DIGEST_LENGTH);
if (cmp == 0)
return -1; /* object already indexed */
else if (cmp > 0)
fprintf(stderr, "object IDs:\n");
for (i = 0; i < nindexed; i++) {
char hex[SHA1_DIGEST_STRING_LENGTH];
- got_sha1_digest_to_str(packidx->hdr.sorted_ids[i].sha1,
+ got_sha1_digest_to_str(packidx->hdr.sorted_ids[i].hash,
hex, sizeof(hex));
fprintf(stderr, "%s\n", hex);
}
{
int i;
- memcpy(packidx->hdr.sorted_ids[idx].sha1, obj->id.sha1,
+ memcpy(packidx->hdr.sorted_ids[idx].hash, obj->id.hash,
SHA1_DIGEST_LENGTH);
packidx->hdr.crc32[idx] = htobe32(obj->crc);
if (obj->off < GOT_PACKIDX_OFFSET_VAL_IS_LARGE_IDX)
packidx->nlargeobj++;
}
- for (i = obj->id.sha1[0]; i <= 0xff; i++) {
+ for (i = obj->id.hash[0]; i <= 0xff; i++) {
uint32_t n = be32toh(packidx->hdr.fanout_table[i]);
packidx->hdr.fanout_table[i] = htobe32(n + 1);
}
const struct got_error *
got_pack_index(struct got_pack *pack, int idxfd, FILE *tmpfile,
- FILE *delta_base_file, FILE *delta_accum_file, uint8_t *pack_sha1_expected,
+ FILE *delta_base_file, FILE *delta_accum_file, uint8_t *pack_hash_expected,
got_pack_index_progress_cb progress_cb, void *progress_arg,
struct got_ratelimit *rl)
{
struct got_packfile_hdr hdr;
struct got_packidx packidx;
char buf[8];
- char pack_sha1[SHA1_DIGEST_LENGTH];
+ char pack_hash[SHA1_DIGEST_LENGTH];
uint32_t nobj, nvalid, nloose, nresolved = 0, i;
struct got_indexed_object *objects = NULL, *obj;
SHA1_CTX ctx;
* Having done a full pass over the pack file and can now
* verify its checksum.
*/
- SHA1Final(pack_sha1, &ctx);
+ SHA1Final(pack_hash, &ctx);
- if (memcmp(pack_sha1_expected, pack_sha1, SHA1_DIGEST_LENGTH) != 0) {
+ if (memcmp(pack_hash_expected, pack_hash, SHA1_DIGEST_LENGTH) != 0) {
err = got_error(GOT_ERR_PACKFILE_CSUM);
goto done;
}
goto done;
}
- memcpy(pack_sha1_expected, pack->map +
+ memcpy(pack_hash_expected, pack->map +
pack->filesize - SHA1_DIGEST_LENGTH,
SHA1_DIGEST_LENGTH);
} else {
err = got_error_from_errno("lseek");
goto done;
}
- n = read(pack->fd, pack_sha1_expected, SHA1_DIGEST_LENGTH);
+ n = read(pack->fd, pack_hash_expected, SHA1_DIGEST_LENGTH);
if (n == -1) {
err = got_error_from_errno("read");
goto done;
goto done;
}
}
- if (memcmp(pack_sha1, pack_sha1_expected, SHA1_DIGEST_LENGTH) != 0) {
+ if (memcmp(pack_hash, pack_hash_expected, SHA1_DIGEST_LENGTH) != 0) {
err = got_error_msg(GOT_ERR_BAD_PACKFILE,
"bad checksum in pack file trailer");
goto done;
if (err)
goto done;
}
- err = got_pack_hwrite(idxfd, pack_sha1, SHA1_DIGEST_LENGTH, &ctx);
+ err = got_pack_hwrite(idxfd, pack_hash, SHA1_DIGEST_LENGTH, &ctx);
if (err)
goto done;
blob - 6227992d23f21048e0238cc7a3bfe018b85c9cf5
blob + 759d146cf9afa72806ed93656441706e3bc78105
--- lib/patch.c
+++ lib/patch.c
return err;
idptr = matched_id;
} else {
- if (!got_parse_sha1_digest(id.sha1, blobid))
+ if (!got_parse_sha1_digest(id.hash, blobid))
return got_error(GOT_ERR_BAD_OBJ_ID_STR);
idptr = &id;
}
err = got_object_tree_find_path(&id, NULL, repo, tree, path);
if (err)
return err;
- got_sha1_digest_to_str(id->sha1, p->blob, sizeof(p->blob));
- got_sha1_digest_to_str(commit_id->sha1, p->cid, sizeof(p->cid));
+ got_sha1_digest_to_str(id->hash, p->blob, sizeof(p->blob));
+ got_sha1_digest_to_str(commit_id->hash, p->cid, sizeof(p->cid));
free(id);
err = open_blob(apath, afile, p->blob, repo);
*do_merge = err == NULL;
blob - a54ba7c0e2d8f3fc5ac97dacc39c1d54cb028eb7
blob + b85b1a7e65489e1c22483a74c27de91855799e9d
--- lib/privsep.c
+++ lib/privsep.c
const struct got_error *
got_privsep_recv_fetch_progress(int *done, struct got_object_id **id,
char **refname, struct got_pathlist_head *symrefs, char **server_progress,
- off_t *packfile_size, uint8_t *pack_sha1, struct imsgbuf *ibuf)
+ off_t *packfile_size, uint8_t *pack_hash, struct imsgbuf *ibuf)
{
const struct got_error *err = NULL;
struct imsg imsg;
*refname = NULL;
*server_progress = NULL;
*packfile_size = 0;
- memset(pack_sha1, 0, SHA1_DIGEST_LENGTH);
+ memset(pack_hash, 0, SHA1_DIGEST_LENGTH);
err = got_privsep_recv_imsg(&imsg, ibuf, 0);
if (err)
err = got_error(GOT_ERR_PRIVSEP_MSG);
break;
}
- memcpy(pack_sha1, imsg.data, SHA1_DIGEST_LENGTH);
+ memcpy(pack_hash, imsg.data, SHA1_DIGEST_LENGTH);
*done = 1;
break;
default:
}
const struct got_error *
-got_privsep_send_index_pack_req(struct imsgbuf *ibuf, uint8_t *pack_sha1,
+got_privsep_send_index_pack_req(struct imsgbuf *ibuf, uint8_t *pack_hash,
int fd)
{
const struct got_error *err = NULL;
/* Keep in sync with struct got_imsg_index_pack_request */
if (imsg_compose(ibuf, GOT_IMSG_IDXPACK_REQUEST, 0, 0, fd,
- pack_sha1, SHA1_DIGEST_LENGTH) == -1) {
+ pack_hash, SHA1_DIGEST_LENGTH) == -1) {
err = got_error_from_errno("imsg_compose INDEX_REQUEST");
close(fd);
return err;
te_name = buf + sizeof(ite);
memcpy(te->name, te_name, ite.namelen);
te->name[ite.namelen] = '\0';
- memcpy(te->id.sha1, ite.id, SHA1_DIGEST_LENGTH);
+ memcpy(te->id.hash, ite.id, SHA1_DIGEST_LENGTH);
te->mode = ite.mode;
te->idx = *nentries;
(*nentries)++;
return got_error_from_errno("malloc");
itag = (struct got_imsg_tag_object *)buf;
- memcpy(itag->id, tag->id.sha1, sizeof(itag->id));
+ memcpy(itag->id, tag->id.hash, sizeof(itag->id));
itag->obj_type = tag->obj_type;
itag->tag_len = tag_len;
itag->tagger_len = tagger_len;
break;
}
- memcpy((*tag)->id.sha1, itag->id, SHA1_DIGEST_LENGTH);
+ memcpy((*tag)->id.hash, itag->id, SHA1_DIGEST_LENGTH);
(*tag)->tag = strndup(imsg.data + len, itag->tag_len);
if ((*tag)->tag == NULL) {
if (wbuf == NULL)
return got_error_from_errno(
"imsg_create COMMIT_TRAVERSAL_REQUEST");
- if (imsg_add(wbuf, id->sha1, SHA1_DIGEST_LENGTH) == -1)
+ if (imsg_add(wbuf, id->hash, SHA1_DIGEST_LENGTH) == -1)
return got_error_from_errno("imsg_add "
"COMMIT_TRAVERSAL_REQUEST");
if (imsg_add(wbuf, &idx, sizeof(idx)) == -1)
}
for (i = 0; i < icommits->ncommits; i++) {
struct got_object_qid *qid;
- uint8_t *sha1 = (uint8_t *)imsg.data +
+ uint8_t *hash = (uint8_t *)imsg.data +
sizeof(*icommits) + i * SHA1_DIGEST_LENGTH;
err = got_object_qid_alloc_partial(&qid);
if (err)
break;
- memcpy(qid->id.sha1, sha1, SHA1_DIGEST_LENGTH);
+ memcpy(qid->id.hash, hash, SHA1_DIGEST_LENGTH);
STAILQ_INSERT_TAIL(commit_ids, qid, entry);
/* The last commit may contain a change. */
if (wbuf == NULL)
return got_error_from_errno("imsg_create ENUMERATED_TREE");
- if (imsg_add(wbuf, tree_id->sha1, SHA1_DIGEST_LENGTH) == -1)
+ if (imsg_add(wbuf, tree_id->hash, SHA1_DIGEST_LENGTH) == -1)
return got_error_from_errno("imsg_add ENUMERATED_TREE");
if (imsg_add(wbuf, &nentries, sizeof(nentries)) == -1)
return got_error_from_errno("imsg_add ENUMERATED_TREE");
break;
}
icommit = (struct got_imsg_enumerated_commit *)imsg.data;
- memcpy(commit_id.sha1, icommit->id, SHA1_DIGEST_LENGTH);
+ memcpy(commit_id.hash, icommit->id, SHA1_DIGEST_LENGTH);
mtime = icommit->mtime;
have_commit = 1;
break;
err = got_error(GOT_ERR_PRIVSEP_LEN);
break;
}
- memcpy(tree_id.sha1, itree->id, sizeof(tree_id.sha1));
+ memcpy(tree_id.hash, itree->id, sizeof(tree_id.hash));
free(path);
path = strndup(imsg.data + sizeof(*itree), path_len);
if (path == NULL) {
struct got_imsg_commit_painting_request ireq;
memset(&ireq, 0, sizeof(ireq));
- memcpy(ireq.id, id->sha1, sizeof(ireq.id));
+ memcpy(ireq.id, id->hash, sizeof(ireq.id));
ireq.idx = idx;
ireq.color = color;
color = (intptr_t)qid->data;
/* Keep in sync with struct got_imsg_painted_commit! */
- if (imsg_add(wbuf, qid->id.sha1, SHA1_DIGEST_LENGTH) == -1)
+ if (imsg_add(wbuf, qid->id.hash, SHA1_DIGEST_LENGTH) == -1)
return got_error_from_errno("imsg_add PAINTED_COMMITS");
if (imsg_add(wbuf, &color, sizeof(color)) == -1)
return got_error_from_errno("imsg_add PAINTED_COMMITS");
if (icommits.present_in_pack) {
struct got_object_id id;
- memcpy(id.sha1, icommit.id, SHA1_DIGEST_LENGTH);
+ memcpy(id.hash, icommit.id, SHA1_DIGEST_LENGTH);
err = cb(cb_arg, &id, icommit.color);
if (err)
break;
err = got_object_qid_alloc_partial(&qid);
if (err)
break;
- memcpy(qid->id.sha1, icommit.id,
+ memcpy(qid->id.hash, icommit.id,
SHA1_DIGEST_LENGTH);
qid->data = (void *)icommit.color;
STAILQ_INSERT_TAIL(new_ids, qid, entry);
blob - ed17dd58dd4864a824f87a1d54d2cd42169bef1e
blob + c6f5023144580d7c199ef6b8a5a01563683a2295
--- lib/reference.c
+++ lib/reference.c
return parse_symref(ref, name, line);
}
- if (!got_parse_sha1_digest(id.sha1, line))
+ if (!got_parse_sha1_digest(id.hash, line))
return got_error(GOT_ERR_BAD_REF_DATA);
return alloc_ref(ref, name, &id, 0, mtime);
if (line[0] == '#' || line[0] == '^')
return NULL;
- if (!got_parse_sha1_digest(id.sha1, line))
+ if (!got_parse_sha1_digest(id.hash, line))
return got_error(GOT_ERR_BAD_REF_DATA);
if (abs_refname) {
blob - e754fef75fcc2d66013a8f85b64547acc0aea1c4
blob + 035b7755844e1535807379a27b51c214e2352f0a
--- lib/repository.c
+++ lib/repository.c
bf = get_packidx_bloom_filter(repo, path_packidx, strlen(path_packidx));
if (bf)
- return bloom_check(bf->bloom, id->sha1, sizeof(id->sha1));
+ return bloom_check(bf->bloom, id->hash, sizeof(id->hash));
/* No bloom filter means this pack index must be searched. */
return 1;
for (i = 0; i < nobjects; i++) {
struct got_packidx_object_id *id;
id = &packidx->hdr.sorted_ids[i];
- bloom_add(bf->bloom, id->sha1, sizeof(id->sha1));
+ bloom_add(bf->bloom, id->hash, sizeof(id->hash));
}
RB_INSERT(got_packidx_bloom_filter_tree,
goto done;
}
- if (!got_parse_sha1_digest(id.sha1, id_str))
+ if (!got_parse_sha1_digest(id.hash, id_str))
continue;
/*
goto done;
}
- if (!got_parse_sha1_digest(id.sha1, id_str)) {
+ if (!got_parse_sha1_digest(id.hash, id_str)) {
free(id_str);
continue;
}
blob - 0be05225c5acde90af06fcbe60d29ec6a8044bbe
blob + ae3dbc005fc34c20b89ea3db6c49aa8107757906
--- lib/repository_admin.c
+++ lib/repository_admin.c
struct got_object_id **ours = NULL, **theirs = NULL;
int nours = 0, ntheirs = 0, packfd = -1, i;
char *tmpfile_path = NULL, *path = NULL, *packfile_path = NULL;
- char *sha1_str = NULL;
+ char *hash_str = NULL;
FILE *delta_cache = NULL;
struct got_ratelimit rl;
goto done;
}
- err = got_pack_create((*pack_hash)->sha1, packfd, delta_cache,
+ err = got_pack_create((*pack_hash)->hash, packfd, delta_cache,
theirs, ntheirs, ours, nours, repo, loose_obj_only, 0,
progress_cb, progress_arg, &rl, cancel_cb, cancel_arg);
if (err)
goto done;
- err = got_object_id_str(&sha1_str, *pack_hash);
+ err = got_object_id_str(&hash_str, *pack_hash);
if (err)
goto done;
if (asprintf(&packfile_path, "%s/%s/pack-%s.pack",
got_repo_get_path_git_dir(repo), GOT_OBJECTS_PACK_DIR,
- sha1_str) == -1) {
+ hash_str) == -1) {
err = got_error_from_errno("asprintf");
goto done;
}
err = got_error_from_errno2("unlink", tmpfile_path);
free(tmpfile_path);
free(packfile_path);
- free(sha1_str);
+ free(hash_str);
free(path);
if (err) {
free(*pack_hash);
err = got_error_from_errno("dup");
goto done;
}
- err = got_privsep_send_index_pack_req(&idxibuf, pack_hash->sha1,
+ err = got_privsep_send_index_pack_req(&idxibuf, pack_hash->hash,
npackfd);
if (err != NULL)
goto done;
goto done;
}
*dot = '\0';
- if (!got_parse_sha1_digest(id.sha1, p)) {
+ if (!got_parse_sha1_digest(id.hash, p)) {
err = got_error_fmt(GOT_ERR_BAD_PATH,
"'%s' is not a valid pack file name",
packfile_name);
break;
}
oid = &packidx->hdr.sorted_ids[i];
- memcpy(id.sha1, oid->sha1, SHA1_DIGEST_LENGTH);
+ memcpy(id.hash, oid->hash, SHA1_DIGEST_LENGTH);
offset = got_packidx_get_object_offset(packidx, i);
if (offset == -1) {
}
memset(&id, 0, sizeof(id));
- if (!got_parse_sha1_digest(id.sha1, id_str)) {
+ if (!got_parse_sha1_digest(id.hash, id_str)) {
free(id_str);
continue;
}
blob - ec59732b5d47bf06ab52a0c1cced9366c7816e51
blob + 59601906a0dc01515656d60f8ca2828c435acf2c
--- lib/send.c
+++ lib/send.c
int refs_to_send = 0, refs_to_delete = 0;
off_t bytes_sent = 0, bytes_sent_cur = 0;
struct pack_progress_arg ppa;
- uint8_t packsha1[SHA1_DIGEST_LENGTH];
+ uint8_t packhash[SHA1_DIGEST_LENGTH];
int packfd = -1;
FILE *delta_cache = NULL;
memset(&ppa, 0, sizeof(ppa));
ppa.progress_cb = progress_cb;
ppa.progress_arg = progress_arg;
- err = got_pack_create(packsha1, packfd, delta_cache,
+ err = got_pack_create(packhash, packfd, delta_cache,
their_ids, ntheirs, our_ids, nours, repo, 0, 1,
pack_progress, &ppa, &rl, cancel_cb, cancel_arg);
if (err)
blob - 463be5bf1c6d96c601149d660c3857be5d14931d
blob + 7e768b7563d7862a3e44bda3804c8d781a8e307e
--- lib/worktree.c
+++ lib/worktree.c
return err;
err = got_fileindex_entry_update(new_ie, wt_fd, path,
- blob_id->sha1, base_commit_id->sha1, 1);
+ blob_id->hash, base_commit_id->hash, 1);
if (err)
goto done;
if (staged_status == GOT_STATUS_MODIFY ||
staged_status == GOT_STATUS_ADD)
- memcpy(id.sha1, ie->staged_blob_sha1, sizeof(id.sha1));
+ memcpy(id.hash, ie->staged_blob_hash, sizeof(id.hash));
else
- memcpy(id.sha1, ie->blob_sha1, sizeof(id.sha1));
+ memcpy(id.hash, ie->blob_hash, sizeof(id.hash));
fd1 = got_opentempfd();
if (fd1 == -1) {
{
if (status == GOT_STATUS_NO_CHANGE && stat_info_differs(ie, sb))
return got_fileindex_entry_update(ie, wt_fd, path,
- ie->blob_sha1, ie->commit_sha1, 1);
+ ie->blob_hash, ie->commit_hash, 1);
return NULL;
}
* updating contents of this file.
*/
if (got_fileindex_entry_has_commit(ie) &&
- memcmp(ie->commit_sha1, worktree->base_commit_id->sha1,
+ memcmp(ie->commit_hash, worktree->base_commit_id->hash,
SHA1_DIGEST_LENGTH) == 0) {
/* Same commit. */
err = sync_timestamps(worktree->root_fd,
goto done;
}
if (got_fileindex_entry_has_blob(ie) &&
- memcmp(ie->blob_sha1, te->id.sha1,
+ memcmp(ie->blob_hash, te->id.hash,
SHA1_DIGEST_LENGTH) == 0) {
/* Different commit but the same blob. */
err = sync_timestamps(worktree->root_fd,
goto done;
}
struct got_object_id id2;
- memcpy(id2.sha1, ie->blob_sha1, SHA1_DIGEST_LENGTH);
+ memcpy(id2.hash, ie->blob_hash, SHA1_DIGEST_LENGTH);
err = got_object_open_as_blob(&blob2, repo, &id2, 8192,
fd2);
if (err)
}
if (got_fileindex_entry_has_commit(ie)) {
char id_str[SHA1_DIGEST_STRING_LENGTH];
- if (got_sha1_digest_to_str(ie->commit_sha1, id_str,
+ if (got_sha1_digest_to_str(ie->commit_hash, id_str,
sizeof(id_str)) == NULL) {
err = got_error_path(id_str,
GOT_ERR_BAD_OBJ_ID_STR);
* unmodified files again.
*/
err = got_fileindex_entry_update(ie, worktree->root_fd, path,
- blob->id.sha1, worktree->base_commit_id->sha1,
+ blob->id.hash, worktree->base_commit_id->hash,
update_timestamps);
} else if (status == GOT_STATUS_MODE_CHANGE) {
err = got_fileindex_entry_update(ie, worktree->root_fd, path,
- blob->id.sha1, worktree->base_commit_id->sha1, 0);
+ blob->id.hash, worktree->base_commit_id->hash, 0);
} else if (status == GOT_STATUS_DELETE) {
err = (*progress_cb)(progress_arg, GOT_STATUS_MERGE, path);
if (err)
goto done;
err = got_fileindex_entry_update(ie, worktree->root_fd, path,
- blob->id.sha1, worktree->base_commit_id->sha1, 0);
+ blob->id.hash, worktree->base_commit_id->hash, 0);
if (err)
goto done;
} else {
if (ie) {
err = got_fileindex_entry_update(ie,
- worktree->root_fd, path, blob->id.sha1,
- worktree->base_commit_id->sha1, 1);
+ worktree->root_fd, path, blob->id.hash,
+ worktree->base_commit_id->hash, 1);
} else {
err = create_fileindex_entry(&ie, fileindex,
worktree->base_commit_id, worktree->root_fd, path,
if (got_fileindex_entry_was_skipped(ie))
return NULL;
- if (memcmp(ie->commit_sha1, a->base_commit_id->sha1,
+ if (memcmp(ie->commit_hash, a->base_commit_id->hash,
SHA1_DIGEST_LENGTH) == 0)
return NULL;
if (err)
return err;
}
- memcpy(ie->commit_sha1, a->base_commit_id->sha1, SHA1_DIGEST_LENGTH);
+ memcpy(ie->commit_hash, a->base_commit_id->hash, SHA1_DIGEST_LENGTH);
return NULL;
}
goto done;
if (status == GOT_STATUS_DELETE) {
err = got_fileindex_entry_update(ie,
- a->worktree->root_fd, path2, blob2->id.sha1,
- a->worktree->base_commit_id->sha1, 0);
+ a->worktree->root_fd, path2, blob2->id.hash,
+ a->worktree->base_commit_id->hash, 0);
if (err)
goto done;
}
/* Reject merges into a work tree with mixed base commits. */
if (got_fileindex_entry_has_commit(ie) &&
- memcmp(ie->commit_sha1, worktree->base_commit_id->sha1,
+ memcmp(ie->commit_hash, worktree->base_commit_id->hash,
SHA1_DIGEST_LENGTH) != 0)
return got_error(GOT_ERR_MIXED_COMMITS);
return NULL;
if (got_fileindex_entry_has_blob(ie)) {
- memcpy(blob_id.sha1, ie->blob_sha1, SHA1_DIGEST_LENGTH);
+ memcpy(blob_id.hash, ie->blob_hash, SHA1_DIGEST_LENGTH);
blob_idp = &blob_id;
}
if (got_fileindex_entry_has_commit(ie)) {
- memcpy(commit_id.sha1, ie->commit_sha1, SHA1_DIGEST_LENGTH);
+ memcpy(commit_id.hash, ie->commit_hash, SHA1_DIGEST_LENGTH);
commit_idp = &commit_id;
}
if (staged_status == GOT_STATUS_ADD ||
staged_status == GOT_STATUS_MODIFY) {
- memcpy(staged_blob_id.sha1, ie->staged_blob_sha1,
+ memcpy(staged_blob_id.hash, ie->staged_blob_hash,
SHA1_DIGEST_LENGTH);
staged_blob_idp = &staged_blob_id;
}
if (!got_path_is_child(ie->path, a->status_path, a->status_path_len))
return NULL;
- memcpy(blob_id.sha1, ie->blob_sha1, SHA1_DIGEST_LENGTH);
- memcpy(commit_id.sha1, ie->commit_sha1, SHA1_DIGEST_LENGTH);
+ memcpy(blob_id.hash, ie->blob_hash, SHA1_DIGEST_LENGTH);
+ memcpy(commit_id.hash, ie->commit_hash, SHA1_DIGEST_LENGTH);
if (got_fileindex_entry_has_file_on_disk(ie))
status = GOT_STATUS_MISSING;
else
struct got_object_id id;
if (staged_status == GOT_STATUS_ADD ||
staged_status == GOT_STATUS_MODIFY) {
- memcpy(id.sha1, ie->staged_blob_sha1,
+ memcpy(id.hash, ie->staged_blob_hash,
SHA1_DIGEST_LENGTH);
} else
- memcpy(id.sha1, ie->blob_sha1,
+ memcpy(id.hash, ie->blob_hash,
SHA1_DIGEST_LENGTH);
fd = got_opentempfd();
if (fd == -1) {
status == GOT_STATUS_MODE_CHANGE) {
err = got_fileindex_entry_update(ie,
a->worktree->root_fd, relpath,
- blob->id.sha1,
- a->worktree->base_commit_id->sha1, 1);
+ blob->id.hash,
+ a->worktree->base_commit_id->hash, 1);
if (err)
goto done;
}
err = got_fileindex_entry_update(ie,
worktree->root_fd, relpath,
- ct->staged_blob_id->sha1,
- new_base_commit_id->sha1,
+ ct->staged_blob_id->hash,
+ new_base_commit_id->hash,
!have_staged_files);
} else
err = got_fileindex_entry_update(ie,
worktree->root_fd, relpath,
- ct->blob_id->sha1,
- new_base_commit_id->sha1,
+ ct->blob_id->hash,
+ new_base_commit_id->hash,
!have_staged_files);
} else {
err = got_fileindex_entry_alloc(&ie, pe->path);
if (err)
goto done;
err = got_fileindex_entry_update(ie,
- worktree->root_fd, relpath, ct->blob_id->sha1,
- new_base_commit_id->sha1, 1);
+ worktree->root_fd, relpath, ct->blob_id->hash,
+ new_base_commit_id->hash, 1);
if (err) {
got_fileindex_entry_free(ie);
goto done;
char *ondisk_path;
/* Reject rebase of a work tree with mixed base commits. */
- if (memcmp(ie->commit_sha1, a->worktree->base_commit_id->sha1,
+ if (memcmp(ie->commit_hash, a->worktree->base_commit_id->hash,
SHA1_DIGEST_LENGTH))
return got_error(GOT_ERR_MIXED_COMMITS);
return got_error_from_errno("asprintf");
if (got_fileindex_entry_has_commit(ie)) {
- memcpy(base_commit_id.sha1, ie->commit_sha1,
+ memcpy(base_commit_id.hash, ie->commit_hash,
SHA1_DIGEST_LENGTH);
base_commit_idp = &base_commit_id;
}
path_content ? path_content : ondisk_path, a->repo);
if (err)
break;
- memcpy(ie->staged_blob_sha1, new_staged_blob_id->sha1,
+ memcpy(ie->staged_blob_hash, new_staged_blob_id->hash,
SHA1_DIGEST_LENGTH);
if (status == GOT_STATUS_ADD || staged_status == GOT_STATUS_ADD)
stage = GOT_FILEIDX_STAGE_ADD;
* When staging the reverse of the staged diff,
* implicitly unstage the file.
*/
- if (memcmp(ie->staged_blob_sha1, ie->blob_sha1,
- sizeof(ie->blob_sha1)) == 0) {
+ if (memcmp(ie->staged_blob_hash, ie->blob_hash,
+ sizeof(ie->blob_hash)) == 0) {
got_fileindex_entry_stage_set(ie,
GOT_FILEIDX_STAGE_NONE);
}
goto done;
if (new_staged_blob_id) {
- memcpy(ie->staged_blob_sha1, new_staged_blob_id->sha1,
+ memcpy(ie->staged_blob_hash, new_staged_blob_id->hash,
SHA1_DIGEST_LENGTH);
} else {
got_fileindex_entry_stage_set(ie, GOT_FILEIDX_STAGE_NONE);
return NULL;
if (got_fileindex_entry_has_blob(ie)) {
- memcpy(blob_id.sha1, ie->blob_sha1, SHA1_DIGEST_LENGTH);
+ memcpy(blob_id.hash, ie->blob_hash, SHA1_DIGEST_LENGTH);
blob_idp = &blob_id;
}
stage = got_fileindex_entry_stage_get(ie);
if (stage == GOT_FILEIDX_STAGE_MODIFY ||
stage == GOT_FILEIDX_STAGE_ADD) {
- memcpy(staged_blob_id.sha1, ie->staged_blob_sha1,
+ memcpy(staged_blob_id.hash, ie->staged_blob_hash,
SHA1_DIGEST_LENGTH);
staged_blob_idp = &staged_blob_id;
}
if (got_fileindex_entry_has_commit(ie)) {
- memcpy(commit_id.sha1, ie->commit_sha1, SHA1_DIGEST_LENGTH);
+ memcpy(commit_id.hash, ie->commit_hash, SHA1_DIGEST_LENGTH);
commit_idp = &commit_id;
}
blob - 77ba914fb971f5e412b57bd1633bda6ee0e1f26d
blob + f24f6e6f2f6873e05e6005d3b1a31dfae6218797
--- libexec/got-fetch-pack/got-fetch-pack.c
+++ libexec/got-fetch-pack/got-fetch-pack.c
}
static const struct got_error *
-send_fetch_done(struct imsgbuf *ibuf, uint8_t *pack_sha1)
+send_fetch_done(struct imsgbuf *ibuf, uint8_t *pack_hash)
{
if (imsg_compose(ibuf, GOT_IMSG_FETCH_DONE, 0, 0, -1,
- pack_sha1, SHA1_DIGEST_LENGTH) == -1)
+ pack_hash, SHA1_DIGEST_LENGTH) == -1)
return got_error_from_errno("imsg_compose FETCH");
return got_privsep_flush_imsg(ibuf);
}
}
static const struct got_error *
-fetch_pack(int fd, int packfd, uint8_t *pack_sha1,
+fetch_pack(int fd, int packfd, uint8_t *pack_hash,
struct got_pathlist_head *have_refs, int fetch_all_branches,
struct got_pathlist_head *wanted_branches,
struct got_pathlist_head *wanted_refs, int list_refs_only,
struct got_pathlist_entry *pe;
int sent_my_capabilites = 0, have_sidebands = 0;
int found_branch = 0;
- SHA1_CTX sha1_ctx;
- uint8_t sha1_buf[SHA1_DIGEST_LENGTH];
- size_t sha1_buf_len = 0;
+ SHA1_CTX hash_ctx;
+ uint8_t hash_buf[SHA1_DIGEST_LENGTH];
+ size_t hash_buf_len = 0;
ssize_t w;
struct got_ratelimit rl;
TAILQ_INIT(&symrefs);
- SHA1Init(&sha1_ctx);
+ SHA1Init(&hash_ctx);
got_ratelimit_init(&rl, 0, 500);
have = malloc(refsz * sizeof(have[0]));
goto done;
}
}
- if (!got_parse_sha1_digest(want[nref].sha1, id_str)) {
+ if (!got_parse_sha1_digest(want[nref].hash, id_str)) {
err = got_error(GOT_ERR_BAD_OBJ_ID_STR);
goto done;
}
for (i = 0; i < nref; i++) {
if (got_object_id_cmp(&have[i], &want[i]) == 0)
continue;
- got_sha1_digest_to_str(want[i].sha1, hashstr, sizeof(hashstr));
+ got_sha1_digest_to_str(want[i].hash, hashstr, sizeof(hashstr));
n = snprintf(buf, sizeof(buf), "want %s%s\n", hashstr,
sent_my_capabilites || my_capabilities == NULL ?
"" : my_capabilities);
TAILQ_FOREACH(pe, have_refs, entry) {
struct got_object_id *id = pe->data;
- got_sha1_digest_to_str(id->sha1, hashstr, sizeof(hashstr));
+ got_sha1_digest_to_str(id->hash, hashstr, sizeof(hashstr));
n = snprintf(buf, sizeof(buf), "have %s\n", hashstr);
if (n < 0 || (size_t)n >= sizeof(buf)) {
err = got_error(GOT_ERR_NO_SPACE);
"unexpected message from server");
goto done;
}
- if (!got_parse_sha1_digest(common_id.sha1, buf + 4)) {
+ if (!got_parse_sha1_digest(common_id.hash, buf + 4)) {
err = got_error_msg(GOT_ERR_BAD_PACKET,
"bad object ID in ACK packet from server");
goto done;
* We can assume r > 0 since otherwise the loop would exit.
*/
if (r < SHA1_DIGEST_LENGTH) {
- if (sha1_buf_len < SHA1_DIGEST_LENGTH) {
+ if (hash_buf_len < SHA1_DIGEST_LENGTH) {
/*
* If there's enough buffered + read data to
* fill up the buffer then shift a sufficient
* amount of bytes out at the front to make
* room, mixing those bytes into the checksum.
*/
- if (sha1_buf_len > 0 &&
- sha1_buf_len + r > SHA1_DIGEST_LENGTH) {
- size_t nshift = MIN(sha1_buf_len + r -
- SHA1_DIGEST_LENGTH, sha1_buf_len);
- SHA1Update(&sha1_ctx, sha1_buf, nshift);
- memmove(sha1_buf, sha1_buf + nshift,
- sha1_buf_len - nshift);
- sha1_buf_len -= nshift;
+ if (hash_buf_len > 0 &&
+ hash_buf_len + r > SHA1_DIGEST_LENGTH) {
+ size_t nshift = MIN(hash_buf_len + r -
+ SHA1_DIGEST_LENGTH, hash_buf_len);
+ SHA1Update(&hash_ctx, hash_buf, nshift);
+ memmove(hash_buf, hash_buf + nshift,
+ hash_buf_len - nshift);
+ hash_buf_len -= nshift;
}
/* Buffer potential checksum bytes. */
- memcpy(sha1_buf + sha1_buf_len, buf, r);
- sha1_buf_len += r;
+ memcpy(hash_buf + hash_buf_len, buf, r);
+ hash_buf_len += r;
} else {
/*
* Mix in previously buffered bytes which
* are not part of the checksum after all.
*/
- SHA1Update(&sha1_ctx, sha1_buf, r);
+ SHA1Update(&hash_ctx, hash_buf, r);
/* Update potential checksum buffer. */
- memmove(sha1_buf, sha1_buf + r,
- sha1_buf_len - r);
- memcpy(sha1_buf + sha1_buf_len - r, buf, r);
+ memmove(hash_buf, hash_buf + r,
+ hash_buf_len - r);
+ memcpy(hash_buf + hash_buf_len - r, buf, r);
}
} else {
/* Mix in any previously buffered bytes. */
- SHA1Update(&sha1_ctx, sha1_buf, sha1_buf_len);
+ SHA1Update(&hash_ctx, hash_buf, hash_buf_len);
/* Mix in bytes read minus potential checksum bytes. */
- SHA1Update(&sha1_ctx, buf, r - SHA1_DIGEST_LENGTH);
+ SHA1Update(&hash_ctx, buf, r - SHA1_DIGEST_LENGTH);
/* Buffer potential checksum bytes. */
- memcpy(sha1_buf, buf + r - SHA1_DIGEST_LENGTH,
+ memcpy(hash_buf, buf + r - SHA1_DIGEST_LENGTH,
SHA1_DIGEST_LENGTH);
- sha1_buf_len = SHA1_DIGEST_LENGTH;
+ hash_buf_len = SHA1_DIGEST_LENGTH;
}
/* Write packfile data to temporary pack file. */
if (err)
goto done;
- SHA1Final(pack_sha1, &sha1_ctx);
- if (sha1_buf_len != SHA1_DIGEST_LENGTH ||
- memcmp(pack_sha1, sha1_buf, sha1_buf_len) != 0) {
+ SHA1Final(pack_hash, &hash_ctx);
+ if (hash_buf_len != SHA1_DIGEST_LENGTH ||
+ memcmp(pack_hash, hash_buf, hash_buf_len) != 0) {
err = got_error_msg(GOT_ERR_BAD_PACKFILE,
"pack file checksum mismatch");
}
{
const struct got_error *err = NULL;
int fetchfd = -1, packfd = -1;
- uint8_t pack_sha1[SHA1_DIGEST_LENGTH];
+ uint8_t pack_hash[SHA1_DIGEST_LENGTH];
struct imsgbuf ibuf;
struct imsg imsg;
struct got_pathlist_head have_refs;
}
packfd = imsg.fd;
- err = fetch_pack(fetchfd, packfd, pack_sha1, &have_refs,
+ err = fetch_pack(fetchfd, packfd, pack_hash, &have_refs,
fetch_req.fetch_all_branches, &wanted_branches,
&wanted_refs, fetch_req.list_refs_only, &ibuf);
done:
if (err != NULL)
got_privsep_send_error(&ibuf, err);
else
- err = send_fetch_done(&ibuf, pack_sha1);
+ err = send_fetch_done(&ibuf, pack_hash);
if (err != NULL) {
fprintf(stderr, "%s: %s\n", getprogname(), err->msg);
got_privsep_send_error(&ibuf, err);
blob - 839a953c4f820616b747cbd3fcca9350a558fc68
blob + 6657e503515c41fdf784526799f05c150f19f071
--- libexec/got-read-blob/got-read-blob.c
+++ libexec/got-read-blob/got-read-blob.c
if (err)
goto done;
}
- SHA1Final(id.sha1, &sha1_ctx);
+ SHA1Final(id.hash, &sha1_ctx);
if (got_object_id_cmp(&expected_id, &id) != 0) {
err = got_error_checksum(&expected_id);
goto done;
blob - d3624830234626794cb116fcaee59a11d7cac75b
blob + a4f05c666f9492a89e9916bbdc3a01276c05fca9
--- libexec/got-read-pack/got-read-pack.c
+++ libexec/got-read-pack/got-read-pack.c
struct got_object_id id1, id2;
int idx;
- memcpy(id1.sha1, pte1->id, SHA1_DIGEST_LENGTH);
+ memcpy(id1.hash, pte1->id, SHA1_DIGEST_LENGTH);
idx = got_packidx_get_object_idx(packidx, &id1);
if (idx == -1) {
err = got_error_no_obj(&id1);
if (err)
break;
- memcpy(id2.sha1, pte2->id, SHA1_DIGEST_LENGTH);
+ memcpy(id2.hash, pte2->id, SHA1_DIGEST_LENGTH);
idx = got_packidx_get_object_idx(packidx, &id2);
if (idx == -1) {
err = got_error_no_obj(&id2);
for (i = 0; i < ncommits; i++) {
struct got_object_id *id = &commit_ids[i];
- if (imsg_add(wbuf, id->sha1, SHA1_DIGEST_LENGTH) == -1) {
+ if (imsg_add(wbuf, id->hash, SHA1_DIGEST_LENGTH) == -1) {
return got_error_from_errno(
"imsg_add TRAVERSED_COMMITS");
}
}
commit_ids = new;
}
- memcpy(commit_ids[ncommits - 1].sha1, id.sha1,
+ memcpy(commit_ids[ncommits - 1].hash, id.hash,
SHA1_DIGEST_LENGTH);
pid = STAILQ_FIRST(&commit->parent_ids);
}
if (!changed) {
- memcpy(id.sha1, pid->id.sha1, SHA1_DIGEST_LENGTH);
+ memcpy(id.hash, pid->id.hash, SHA1_DIGEST_LENGTH);
got_object_commit_close(commit);
commit = pcommit;
pcommit = NULL;
err = got_object_qid_alloc_partial(&qid);
if (err)
return err;
- memcpy(&qid->id.sha1, tree_id, SHA1_DIGEST_LENGTH);
+ memcpy(&qid->id.hash, tree_id, SHA1_DIGEST_LENGTH);
qid->data = strdup(path);
if (qid->data == NULL) {
err = got_error_from_errno("strdup");
err = got_object_qid_alloc_partial(&eqid);
if (err)
goto done;
- memcpy(eqid->id.sha1, pte->id, sizeof(eqid->id.sha1));
+ memcpy(eqid->id.hash, pte->id, sizeof(eqid->id.hash));
if (got_object_idset_contains(idset, &eqid->id)) {
got_object_qid_free(eqid);
if (datalen != sizeof(ireq))
return got_error(GOT_ERR_PRIVSEP_LEN);
memcpy(&ireq, imsg->data, sizeof(ireq));
- memcpy(id.sha1, ireq.id, SHA1_DIGEST_LENGTH);
+ memcpy(id.hash, ireq.id, SHA1_DIGEST_LENGTH);
err = queue_commit_id(&ids, &id, ireq.color);
if (err)
blob - 0fd0e6b2e84bfc5519482bd5ae802897596069f2
blob + 67c2a843fa823538aed295a7ae5a72c39b084434
--- libexec/got-send-pack/got-send-pack.c
+++ libexec/got-send-pack/got-send-pack.c
err = got_error_from_errno("malloc");
goto done;
}
- if (!got_parse_sha1_digest(id->sha1, id_str)) {
+ if (!got_parse_sha1_digest(id->hash, id_str)) {
err = got_error(GOT_ERR_BAD_OBJ_ID_STR);
goto done;
}
goto done;
}
- got_sha1_digest_to_str(their_id->sha1, old_hashstr,
+ got_sha1_digest_to_str(their_id->hash, old_hashstr,
sizeof(old_hashstr));
got_sha1_digest_to_str(zero_id, new_hashstr,
sizeof(new_hashstr));
}
continue;
}
- got_sha1_digest_to_str(their_id->sha1, old_hashstr,
+ got_sha1_digest_to_str(their_id->hash, old_hashstr,
sizeof(old_hashstr));
} else {
got_sha1_digest_to_str(zero_id, old_hashstr,
sizeof(old_hashstr));
}
- got_sha1_digest_to_str(id->sha1, new_hashstr,
+ got_sha1_digest_to_str(id->hash, new_hashstr,
sizeof(new_hashstr));
err = describe_refchange(&n, &sent_my_capabilites,
my_capabilities, buf, sizeof(buf), refname,
blob - f473bd34c3797403a9a540f9222323c574a6d2d6
blob + df87d0bd93b9a695ca67ce7fa10d7e1976b50f23
--- regress/idset/idset_test.c
+++ regress/idset/idset_test.c
goto done;
}
- if (!got_parse_sha1_digest(id1.sha1, id_str1)) {
+ if (!got_parse_sha1_digest(id1.hash, id_str1)) {
err = got_error(GOT_ERR_BAD_OBJ_ID_STR);
goto done;
}
- if (!got_parse_sha1_digest(id2.sha1, id_str2)) {
+ if (!got_parse_sha1_digest(id2.hash, id_str2)) {
err = got_error(GOT_ERR_BAD_OBJ_ID_STR);
goto done;
}
- if (!got_parse_sha1_digest(id3.sha1, id_str3)) {
+ if (!got_parse_sha1_digest(id3.hash, id_str3)) {
err = got_error(GOT_ERR_BAD_OBJ_ID_STR);
goto done;
}