hdrlen = format_object_header((char *)hdr, sizeof(hdr), type,
dat->len);
- the_hash_algo->init_fn(&c);
+ git_hash_init(&c, the_hash_algo);
git_hash_update(&c, hdr, hdrlen);
git_hash_update(&c, dat->buf, dat->len);
git_hash_final_oid(&oid, &c);
hdrlen = format_object_header((char *)out_buf, out_sz, OBJ_BLOB, len);
- the_hash_algo->init_fn(&c);
+ git_hash_init(&c, the_hash_algo);
git_hash_update(&c, out_buf, hdrlen);
crc32_begin(pack_file);
output_fd = -1;
nothread_data.pack_fd = input_fd;
}
- the_hash_algo->init_fn(&input_ctx);
+ git_hash_init(&input_ctx, the_hash_algo);
return pack_name;
}
if (!is_delta_type(type)) {
hdrlen = format_object_header(hdr, sizeof(hdr), type, size);
- the_hash_algo->init_fn(&c);
+ git_hash_init(&c, the_hash_algo);
git_hash_update(&c, hdr, hdrlen);
} else
oid = NULL;
/* Check pack integrity */
flush();
- the_hash_algo->init_fn(&tmp_ctx);
+ git_hash_init(&tmp_ctx, the_hash_algo);
git_hash_clone(&tmp_ctx, &input_ctx);
git_hash_final(hash, &tmp_ctx);
if (!hasheq(fill(the_hash_algo->rawsz), hash, the_repository->hash_algo))
char pre_oid_str[GIT_MAX_HEXSZ + 1], post_oid_str[GIT_MAX_HEXSZ + 1];
struct git_hash_ctx ctx;
- the_hash_algo->init_fn(&ctx);
+ git_hash_init(&ctx, the_hash_algo);
oidclr(result, the_repository->hash_algo);
while (strbuf_getwholeline(line_buf, stdin, '\n') != EOF) {
/* RFC 2104 2. (1) */
memset(key, '\0', GIT_MAX_BLKSZ);
if (the_hash_algo->blksz < key_len) {
- the_hash_algo->init_fn(&ctx);
+ git_hash_init(&ctx, the_hash_algo);
git_hash_update(&ctx, key_in, key_len);
git_hash_final(key, &ctx);
} else {
}
/* RFC 2104 2. (3) & (4) */
- the_hash_algo->init_fn(&ctx);
+ git_hash_init(&ctx, the_hash_algo);
git_hash_update(&ctx, k_ipad, sizeof(k_ipad));
git_hash_update(&ctx, text, text_len);
git_hash_final(out, &ctx);
/* RFC 2104 2. (6) & (7) */
- the_hash_algo->init_fn(&ctx);
+ git_hash_init(&ctx, the_hash_algo);
git_hash_update(&ctx, k_opad, sizeof(k_opad));
git_hash_update(&ctx, out, the_hash_algo->rawsz);
git_hash_final(out, &ctx);
/* Case 2.4: If all the above failed, try a hash of the name as a last resort */
header_len = snprintf(header, sizeof(header), "blob %zu", strlen(submodule_name));
- the_hash_algo->init_fn(&ctx);
+ git_hash_init(&ctx, the_hash_algo);
the_hash_algo->update_fn(&ctx, header, header_len);
the_hash_algo->update_fn(&ctx, "\0", 1);
the_hash_algo->update_fn(&ctx, submodule_name, strlen(submodule_name));
/* We don't take any non-flag arguments now.. Maybe some day */
usage(unpack_usage);
}
- the_hash_algo->init_fn(&ctx);
+ git_hash_init(&ctx, the_hash_algo);
unpack_all();
git_hash_update(&ctx, buffer, offset);
- the_hash_algo->init_fn(&tmp_ctx);
+ git_hash_init(&tmp_ctx, the_hash_algo);
git_hash_clone(&tmp_ctx, &ctx);
git_hash_final_oid(&oid, &tmp_ctx);
if (strict) {
f->skip_hash = 0;
f->algop = unsafe_hash_algo(algop);
- f->algop->init_fn(&f->ctx);
+ git_hash_init(&f->ctx, f->algop);
f->buffer_len = opts->buffer_len ? opts->buffer_len : DEFAULT_IO_BUFFER_SIZE;
f->buffer = xmalloc(f->buffer_len);
struct hashfile_checkpoint *checkpoint)
{
memset(checkpoint, 0, sizeof(*checkpoint));
- f->algop->init_fn(&checkpoint->ctx);
+ git_hash_init(&checkpoint->ctx, f->algop);
}
void hashfile_checkpoint(struct hashfile *f, struct hashfile_checkpoint *checkpoint)
if (total_len < algop->rawsz)
return 0; /* say "too short"? */
- algop->init_fn(&ctx);
+ git_hash_init(&ctx, algop);
git_hash_update(&ctx, data, data_len);
git_hash_final(got, &ctx);
int i;
git_hash_final(hash, ctx);
- the_hash_algo->init_fn(ctx);
+ git_hash_init(ctx, the_hash_algo);
/* 20-byte sum, with carry */
for (i = 0; i < the_hash_algo->rawsz; ++i) {
carry += result->hash[i] + hash[i];
struct git_hash_ctx ctx;
struct patch_id_t data;
- the_hash_algo->init_fn(&ctx);
+ git_hash_init(&ctx, the_hash_algo);
memset(&data, 0, sizeof(struct patch_id_t));
data.ctx = &ctx;
oidclr(oid, the_repository->hash_algo);
} else if (!strcmp(ctx->name, DAV_ACTIVELOCK_TOKEN)) {
lock->token = xstrdup(ctx->cdata);
- the_hash_algo->init_fn(&hash_ctx);
+ git_hash_init(&hash_ctx, the_hash_algo);
git_hash_update(&hash_ctx, lock->token, strlen(lock->token));
git_hash_final(lock_token_hash, &hash_ctx);
git_inflate_init(&freq->stream);
- the_hash_algo->init_fn(&freq->c);
+ git_hash_init(&freq->c, the_hash_algo);
freq->hash_ctx_valid = 1;
freq->url = get_remote_object_url(base_url, hex, 0);
git_inflate_end(&freq->stream);
memset(&freq->stream, 0, sizeof(freq->stream));
git_inflate_init(&freq->stream);
- the_hash_algo->init_fn(&freq->c);
+ git_hash_init(&freq->c, the_hash_algo);
if (prev_posn>0) {
prev_posn = 0;
lseek(freq->localfile, 0, SEEK_SET);
hdrlen = format_object_header(hdr, sizeof(hdr), st->type, st->size);
/* Sha1.. */
- r->hash_algo->init_fn(&c);
+ git_hash_init(&c, r->hash_algo);
git_hash_update(&c, hdr, hdrlen);
for (;;) {
char buf[1024 * 16];
struct object_id *oid,
char *hdr, int *hdrlen)
{
- algo->init_fn(c);
+ git_hash_init(c, algo);
git_hash_update(c, hdr, *hdrlen);
git_hash_update(c, buf, len);
git_hash_final_oid(oid, c);
git_deflate_init(stream, cfg->zlib_compression_level);
stream->next_out = buf;
stream->avail_out = buflen;
- algo->init_fn(c);
+ git_hash_init(c, algo);
if (compat && compat_c)
- compat->init_fn(compat_c);
+ git_hash_init(compat_c, compat);
/* Start to feed header to zlib stream */
stream->next_in = (unsigned char *)hdr;
header_len = format_object_header((char *)buf, sizeof(buf),
OBJ_BLOB, size);
- hash_algo->init_fn(&ctx);
+ git_hash_init(&ctx, hash_algo);
git_hash_update(&ctx, buf, header_len);
while (!stream->is_finished) {
header_len = format_object_header((char *)obuf, sizeof(obuf),
OBJ_BLOB, size);
- transaction->base.source->odb->repo->hash_algo->init_fn(&ctx);
+ git_hash_init(&ctx, transaction->base.source->odb->repo->hash_algo);
git_hash_update(&ctx, obuf, header_len);
/*
unsigned long total_read;
int status = Z_OK;
- algop->init_fn(&c);
+ git_hash_init(&c, algop);
git_hash_update(&c, hdr, stream->total_out);
/*
if (!is_pack_valid(p))
return error("packfile %s cannot be accessed", p->pack_name);
- r->hash_algo->init_fn(&ctx);
+ git_hash_init(&ctx, r->hash_algo);
do {
unsigned long remaining;
unsigned char *in = use_pack(p, w_curs, offset, &remaining);
char *buf;
ssize_t read_result;
- hash_algo->init_fn(&old_hash_ctx);
- hash_algo->init_fn(&new_hash_ctx);
+ git_hash_init(&old_hash_ctx, hash_algo);
+ git_hash_init(&new_hash_ctx, hash_algo);
if (lseek(pack_fd, 0, SEEK_SET) != 0)
die_errno("Failed seeking to start of '%s'", pack_name);
* pack, which also means making partial_pack_offset
* big enough not to matter anymore.
*/
- hash_algo->init_fn(&old_hash_ctx);
+ git_hash_init(&old_hash_ctx, hash_algo);
partial_pack_offset = ~partial_pack_offset;
partial_pack_offset -= MSB(partial_pack_offset, 1);
}
if (oideq(&oid, null_oid(the_hash_algo)))
return 0;
- the_hash_algo->init_fn(&c);
+ git_hash_init(&c, the_hash_algo);
git_hash_update(&c, hdr, size - the_hash_algo->rawsz);
git_hash_final(hash, &c);
if (!hasheq(hash, start, the_repository->hash_algo))
*/
if (offset && record_eoie()) {
CALLOC_ARRAY(eoie_c, 1);
- the_hash_algo->init_fn(eoie_c);
+ git_hash_init(eoie_c, the_hash_algo);
}
/*
* "REUC" + <binary representation of M>)
*/
src_offset = offset;
- the_hash_algo->init_fn(&c);
+ git_hash_init(&c, the_hash_algo);
while (src_offset < mmap_size - the_hash_algo->rawsz - EOIE_SIZE_WITH_HEADER) {
/* After an array of active_nr index entries,
* there can be arbitrary number of extended
struct strbuf buf = STRBUF_INIT, out = STRBUF_INIT;
int has_conflicts = 0;
if (hash)
- the_hash_algo->init_fn(&ctx);
+ git_hash_init(&ctx, the_hash_algo);
while (!io->getline(&buf, io)) {
if (is_cmarker(buf.buf, '<', marker_size)) {
static inline void compute_hash(const struct git_hash_algo *algo, struct git_hash_ctx *ctx, uint8_t *final, const void *p, size_t len)
{
- algo->init_fn(ctx);
+ git_hash_init(ctx, algo);
git_hash_update(ctx, p, len);
git_hash_final(final, ctx);
}
die("OOPS");
}
- algop->init_fn(&ctx);
+ git_hash_init(&ctx, algop);
while (1) {
ssize_t sz, this_sz;
/* Write the data as uncompressed zlib */
write_uncompressed_zlib(f, pack_ctx, data, len, algo);
- algo->init_fn(&ctx);
+ git_hash_init(&ctx, algo);
object_header_len = format_object_header(object_header,
sizeof(object_header),
type, len);
f = xfopen(path, "wb");
- algo->init_fn(&pack_ctx);
+ git_hash_init(&pack_ctx, algo);
/* Write pack header */
fwrite_or_die(f, &pack_header, sizeof(pack_header));
unsigned char hash[GIT_MAX_HEXSZ];
const struct git_hash_algo *algop = &hash_algos[i];
- algop->init_fn(&ctx);
+ git_hash_init(&ctx, algop);
git_hash_update(&ctx, data, data_length);
git_hash_final(hash, &ctx);
--- /dev/null
+@@
+identifier f != git_hash_init;
+expression ALGO;
+struct git_hash_ctx *CTX;
+@@
+ f(...) {<...
+- ALGO->init_fn(CTX);
++ git_hash_init(CTX, ALGO);
+ ...>}
if (xgethostname(hostname, sizeof(hostname)))
strbuf_add(&tr2sid_buf, "Localhost", 9);
else {
- algo->init_fn(&ctx);
+ git_hash_init(&ctx, algo);
git_hash_update(&ctx, hostname, strlen(hostname));
git_hash_final(hash, &ctx);
hash_to_hex_algop_r(hex, hash, algo);