hash: stop typedeffing the hash context
We generally avoid using `typedef` in the Git codebase. One exception though is the `git_hash_ctx`, likely because it used to be a union rather than a struct until the preceding commit refactored it. But now that it is a normal `struct` there isn't really a need for a typedef anymore. Drop the typedef and adapt all callers accordingly. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
52eef501e1
commit
7346e340f1
|
|
@ -953,7 +953,7 @@ static int store_object(
|
||||||
unsigned char hdr[96];
|
unsigned char hdr[96];
|
||||||
struct object_id oid;
|
struct object_id oid;
|
||||||
unsigned long hdrlen, deltalen;
|
unsigned long hdrlen, deltalen;
|
||||||
git_hash_ctx c;
|
struct git_hash_ctx c;
|
||||||
git_zstream s;
|
git_zstream s;
|
||||||
|
|
||||||
hdrlen = format_object_header((char *)hdr, sizeof(hdr), type,
|
hdrlen = format_object_header((char *)hdr, sizeof(hdr), type,
|
||||||
|
|
@ -1095,7 +1095,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
|
||||||
struct object_id oid;
|
struct object_id oid;
|
||||||
unsigned long hdrlen;
|
unsigned long hdrlen;
|
||||||
off_t offset;
|
off_t offset;
|
||||||
git_hash_ctx c;
|
struct git_hash_ctx c;
|
||||||
git_zstream s;
|
git_zstream s;
|
||||||
struct hashfile_checkpoint checkpoint;
|
struct hashfile_checkpoint checkpoint;
|
||||||
int status = Z_OK;
|
int status = Z_OK;
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ static unsigned int input_offset, input_len;
|
||||||
static off_t consumed_bytes;
|
static off_t consumed_bytes;
|
||||||
static off_t max_input_size;
|
static off_t max_input_size;
|
||||||
static unsigned deepest_delta;
|
static unsigned deepest_delta;
|
||||||
static git_hash_ctx input_ctx;
|
static struct git_hash_ctx input_ctx;
|
||||||
static uint32_t input_crc32;
|
static uint32_t input_crc32;
|
||||||
static int input_fd, output_fd;
|
static int input_fd, output_fd;
|
||||||
static const char *curr_pack;
|
static const char *curr_pack;
|
||||||
|
|
@ -475,7 +475,7 @@ static void *unpack_entry_data(off_t offset, unsigned long size,
|
||||||
int status;
|
int status;
|
||||||
git_zstream stream;
|
git_zstream stream;
|
||||||
void *buf;
|
void *buf;
|
||||||
git_hash_ctx c;
|
struct git_hash_ctx c;
|
||||||
char hdr[32];
|
char hdr[32];
|
||||||
int hdrlen;
|
int hdrlen;
|
||||||
|
|
||||||
|
|
@ -1248,7 +1248,7 @@ static void parse_pack_objects(unsigned char *hash)
|
||||||
struct ofs_delta_entry *ofs_delta = ofs_deltas;
|
struct ofs_delta_entry *ofs_delta = ofs_deltas;
|
||||||
struct object_id ref_delta_oid;
|
struct object_id ref_delta_oid;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
git_hash_ctx tmp_ctx;
|
struct git_hash_ctx tmp_ctx;
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
progress = start_progress(
|
progress = start_progress(
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ static size_t get_one_patchid(struct object_id *next_oid, struct object_id *resu
|
||||||
int before = -1, after = -1;
|
int before = -1, after = -1;
|
||||||
int diff_is_binary = 0;
|
int diff_is_binary = 0;
|
||||||
char pre_oid_str[GIT_MAX_HEXSZ + 1], post_oid_str[GIT_MAX_HEXSZ + 1];
|
char pre_oid_str[GIT_MAX_HEXSZ + 1], post_oid_str[GIT_MAX_HEXSZ + 1];
|
||||||
git_hash_ctx ctx;
|
struct git_hash_ctx ctx;
|
||||||
|
|
||||||
the_hash_algo->init_fn(&ctx);
|
the_hash_algo->init_fn(&ctx);
|
||||||
oidclr(result, the_repository->hash_algo);
|
oidclr(result, the_repository->hash_algo);
|
||||||
|
|
|
||||||
|
|
@ -566,7 +566,7 @@ static void hmac_hash(unsigned char *out,
|
||||||
unsigned char k_ipad[GIT_MAX_BLKSZ];
|
unsigned char k_ipad[GIT_MAX_BLKSZ];
|
||||||
unsigned char k_opad[GIT_MAX_BLKSZ];
|
unsigned char k_opad[GIT_MAX_BLKSZ];
|
||||||
int i;
|
int i;
|
||||||
git_hash_ctx ctx;
|
struct git_hash_ctx ctx;
|
||||||
|
|
||||||
/* RFC 2104 2. (1) */
|
/* RFC 2104 2. (1) */
|
||||||
memset(key, '\0', GIT_MAX_BLKSZ);
|
memset(key, '\0', GIT_MAX_BLKSZ);
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ static unsigned char buffer[4096];
|
||||||
static unsigned int offset, len;
|
static unsigned int offset, len;
|
||||||
static off_t consumed_bytes;
|
static off_t consumed_bytes;
|
||||||
static off_t max_input_size;
|
static off_t max_input_size;
|
||||||
static git_hash_ctx ctx;
|
static struct git_hash_ctx ctx;
|
||||||
static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;
|
static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;
|
||||||
static struct progress *progress;
|
static struct progress *progress;
|
||||||
|
|
||||||
|
|
@ -614,7 +614,7 @@ int cmd_unpack_objects(int argc,
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct object_id oid;
|
struct object_id oid;
|
||||||
git_hash_ctx tmp_ctx;
|
struct git_hash_ctx tmp_ctx;
|
||||||
|
|
||||||
disable_replace_refs();
|
disable_replace_refs();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ static int already_written(struct bulk_checkin_packfile *state, struct object_id
|
||||||
* with a new pack.
|
* with a new pack.
|
||||||
*/
|
*/
|
||||||
static int stream_blob_to_pack(struct bulk_checkin_packfile *state,
|
static int stream_blob_to_pack(struct bulk_checkin_packfile *state,
|
||||||
git_hash_ctx *ctx, off_t *already_hashed_to,
|
struct git_hash_ctx *ctx, off_t *already_hashed_to,
|
||||||
int fd, size_t size, const char *path,
|
int fd, size_t size, const char *path,
|
||||||
unsigned flags)
|
unsigned flags)
|
||||||
{
|
{
|
||||||
|
|
@ -258,7 +258,7 @@ static int deflate_blob_to_pack(struct bulk_checkin_packfile *state,
|
||||||
const char *path, unsigned flags)
|
const char *path, unsigned flags)
|
||||||
{
|
{
|
||||||
off_t seekback, already_hashed_to;
|
off_t seekback, already_hashed_to;
|
||||||
git_hash_ctx ctx;
|
struct git_hash_ctx ctx;
|
||||||
unsigned char obuf[16384];
|
unsigned char obuf[16384];
|
||||||
unsigned header_len;
|
unsigned header_len;
|
||||||
struct hashfile_checkpoint checkpoint;
|
struct hashfile_checkpoint checkpoint;
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,7 @@ uint32_t crc32_end(struct hashfile *f)
|
||||||
int hashfile_checksum_valid(const unsigned char *data, size_t total_len)
|
int hashfile_checksum_valid(const unsigned char *data, size_t total_len)
|
||||||
{
|
{
|
||||||
unsigned char got[GIT_MAX_RAWSZ];
|
unsigned char got[GIT_MAX_RAWSZ];
|
||||||
git_hash_ctx ctx;
|
struct git_hash_ctx ctx;
|
||||||
const struct git_hash_algo *algop = unsafe_hash_algo(the_hash_algo);
|
const struct git_hash_algo *algop = unsafe_hash_algo(the_hash_algo);
|
||||||
size_t data_len = total_len - algop->rawsz;
|
size_t data_len = total_len - algop->rawsz;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ struct hashfile {
|
||||||
int fd;
|
int fd;
|
||||||
int check_fd;
|
int check_fd;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
git_hash_ctx ctx;
|
struct git_hash_ctx ctx;
|
||||||
off_t total;
|
off_t total;
|
||||||
struct progress *tp;
|
struct progress *tp;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
@ -33,7 +33,7 @@ struct hashfile {
|
||||||
/* Checkpoint */
|
/* Checkpoint */
|
||||||
struct hashfile_checkpoint {
|
struct hashfile_checkpoint {
|
||||||
off_t offset;
|
off_t offset;
|
||||||
git_hash_ctx ctx;
|
struct git_hash_ctx ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
void hashfile_checkpoint_init(struct hashfile *, struct hashfile_checkpoint *);
|
void hashfile_checkpoint_init(struct hashfile *, struct hashfile_checkpoint *);
|
||||||
|
|
|
||||||
10
diff.c
10
diff.c
|
|
@ -6392,7 +6392,7 @@ static void diff_summary(struct diff_options *opt, struct diff_filepair *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct patch_id_t {
|
struct patch_id_t {
|
||||||
git_hash_ctx *ctx;
|
struct git_hash_ctx *ctx;
|
||||||
int patchlen;
|
int patchlen;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -6409,7 +6409,7 @@ static int remove_space(char *line, int len)
|
||||||
return dst - line;
|
return dst - line;
|
||||||
}
|
}
|
||||||
|
|
||||||
void flush_one_hunk(struct object_id *result, git_hash_ctx *ctx)
|
void flush_one_hunk(struct object_id *result, struct git_hash_ctx *ctx)
|
||||||
{
|
{
|
||||||
unsigned char hash[GIT_MAX_RAWSZ];
|
unsigned char hash[GIT_MAX_RAWSZ];
|
||||||
unsigned short carry = 0;
|
unsigned short carry = 0;
|
||||||
|
|
@ -6439,12 +6439,12 @@ static int patch_id_consume(void *priv, char *line, unsigned long len)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void patch_id_add_string(git_hash_ctx *ctx, const char *str)
|
static void patch_id_add_string(struct git_hash_ctx *ctx, const char *str)
|
||||||
{
|
{
|
||||||
the_hash_algo->update_fn(ctx, str, strlen(str));
|
the_hash_algo->update_fn(ctx, str, strlen(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void patch_id_add_mode(git_hash_ctx *ctx, unsigned mode)
|
static void patch_id_add_mode(struct git_hash_ctx *ctx, unsigned mode)
|
||||||
{
|
{
|
||||||
/* large enough for 2^32 in octal */
|
/* large enough for 2^32 in octal */
|
||||||
char buf[12];
|
char buf[12];
|
||||||
|
|
@ -6457,7 +6457,7 @@ static int diff_get_patch_id(struct diff_options *options, struct object_id *oid
|
||||||
{
|
{
|
||||||
struct diff_queue_struct *q = &diff_queued_diff;
|
struct diff_queue_struct *q = &diff_queued_diff;
|
||||||
int i;
|
int i;
|
||||||
git_hash_ctx ctx;
|
struct git_hash_ctx ctx;
|
||||||
struct patch_id_t data;
|
struct patch_id_t data;
|
||||||
|
|
||||||
the_hash_algo->init_fn(&ctx);
|
the_hash_algo->init_fn(&ctx);
|
||||||
|
|
|
||||||
2
diff.h
2
diff.h
|
|
@ -644,7 +644,7 @@ void run_diff_index(struct rev_info *revs, unsigned int option);
|
||||||
|
|
||||||
int do_diff_cache(const struct object_id *, struct diff_options *);
|
int do_diff_cache(const struct object_id *, struct diff_options *);
|
||||||
int diff_flush_patch_id(struct diff_options *, struct object_id *, int);
|
int diff_flush_patch_id(struct diff_options *, struct object_id *, int);
|
||||||
void flush_one_hunk(struct object_id *result, git_hash_ctx *ctx);
|
void flush_one_hunk(struct object_id *result, struct git_hash_ctx *ctx);
|
||||||
|
|
||||||
int diff_result_code(struct rev_info *);
|
int diff_result_code(struct rev_info *);
|
||||||
|
|
||||||
|
|
|
||||||
11
hash.h
11
hash.h
|
|
@ -241,13 +241,12 @@ struct git_hash_ctx {
|
||||||
git_SHA256_CTX sha256;
|
git_SHA256_CTX sha256;
|
||||||
} state;
|
} state;
|
||||||
};
|
};
|
||||||
typedef struct git_hash_ctx git_hash_ctx;
|
|
||||||
|
|
||||||
typedef void (*git_hash_init_fn)(git_hash_ctx *ctx);
|
typedef void (*git_hash_init_fn)(struct git_hash_ctx *ctx);
|
||||||
typedef void (*git_hash_clone_fn)(git_hash_ctx *dst, const git_hash_ctx *src);
|
typedef void (*git_hash_clone_fn)(struct git_hash_ctx *dst, const struct git_hash_ctx *src);
|
||||||
typedef void (*git_hash_update_fn)(git_hash_ctx *ctx, const void *in, size_t len);
|
typedef void (*git_hash_update_fn)(struct git_hash_ctx *ctx, const void *in, size_t len);
|
||||||
typedef void (*git_hash_final_fn)(unsigned char *hash, git_hash_ctx *ctx);
|
typedef void (*git_hash_final_fn)(unsigned char *hash, struct git_hash_ctx *ctx);
|
||||||
typedef void (*git_hash_final_oid_fn)(struct object_id *oid, git_hash_ctx *ctx);
|
typedef void (*git_hash_final_oid_fn)(struct object_id *oid, struct git_hash_ctx *ctx);
|
||||||
|
|
||||||
struct git_hash_algo {
|
struct git_hash_algo {
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -760,7 +760,7 @@ static void handle_lockprop_ctx(struct xml_ctx *ctx, int tag_closed)
|
||||||
static void handle_new_lock_ctx(struct xml_ctx *ctx, int tag_closed)
|
static void handle_new_lock_ctx(struct xml_ctx *ctx, int tag_closed)
|
||||||
{
|
{
|
||||||
struct remote_lock *lock = (struct remote_lock *)ctx->userData;
|
struct remote_lock *lock = (struct remote_lock *)ctx->userData;
|
||||||
git_hash_ctx hash_ctx;
|
struct git_hash_ctx hash_ctx;
|
||||||
unsigned char lock_token_hash[GIT_MAX_RAWSZ];
|
unsigned char lock_token_hash[GIT_MAX_RAWSZ];
|
||||||
|
|
||||||
if (tag_closed && ctx->cdata) {
|
if (tag_closed && ctx->cdata) {
|
||||||
|
|
|
||||||
2
http.h
2
http.h
|
|
@ -228,7 +228,7 @@ struct http_object_request {
|
||||||
long http_code;
|
long http_code;
|
||||||
struct object_id oid;
|
struct object_id oid;
|
||||||
struct object_id real_oid;
|
struct object_id real_oid;
|
||||||
git_hash_ctx c;
|
struct git_hash_ctx c;
|
||||||
git_zstream stream;
|
git_zstream stream;
|
||||||
int zret;
|
int zret;
|
||||||
int rename;
|
int rename;
|
||||||
|
|
|
||||||
|
|
@ -86,82 +86,82 @@ static const struct object_id null_oid_sha256 = {
|
||||||
.algo = GIT_HASH_SHA256,
|
.algo = GIT_HASH_SHA256,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void git_hash_sha1_init(git_hash_ctx *ctx)
|
static void git_hash_sha1_init(struct git_hash_ctx *ctx)
|
||||||
{
|
{
|
||||||
git_SHA1_Init(&ctx->state.sha1);
|
git_SHA1_Init(&ctx->state.sha1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void git_hash_sha1_clone(git_hash_ctx *dst, const git_hash_ctx *src)
|
static void git_hash_sha1_clone(struct git_hash_ctx *dst, const struct git_hash_ctx *src)
|
||||||
{
|
{
|
||||||
git_SHA1_Clone(&dst->state.sha1, &src->state.sha1);
|
git_SHA1_Clone(&dst->state.sha1, &src->state.sha1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void git_hash_sha1_update(git_hash_ctx *ctx, const void *data, size_t len)
|
static void git_hash_sha1_update(struct git_hash_ctx *ctx, const void *data, size_t len)
|
||||||
{
|
{
|
||||||
git_SHA1_Update(&ctx->state.sha1, data, len);
|
git_SHA1_Update(&ctx->state.sha1, data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void git_hash_sha1_final(unsigned char *hash, git_hash_ctx *ctx)
|
static void git_hash_sha1_final(unsigned char *hash, struct git_hash_ctx *ctx)
|
||||||
{
|
{
|
||||||
git_SHA1_Final(hash, &ctx->state.sha1);
|
git_SHA1_Final(hash, &ctx->state.sha1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void git_hash_sha1_final_oid(struct object_id *oid, git_hash_ctx *ctx)
|
static void git_hash_sha1_final_oid(struct object_id *oid, struct git_hash_ctx *ctx)
|
||||||
{
|
{
|
||||||
git_SHA1_Final(oid->hash, &ctx->state.sha1);
|
git_SHA1_Final(oid->hash, &ctx->state.sha1);
|
||||||
memset(oid->hash + GIT_SHA1_RAWSZ, 0, GIT_MAX_RAWSZ - GIT_SHA1_RAWSZ);
|
memset(oid->hash + GIT_SHA1_RAWSZ, 0, GIT_MAX_RAWSZ - GIT_SHA1_RAWSZ);
|
||||||
oid->algo = GIT_HASH_SHA1;
|
oid->algo = GIT_HASH_SHA1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void git_hash_sha1_init_unsafe(git_hash_ctx *ctx)
|
static void git_hash_sha1_init_unsafe(struct git_hash_ctx *ctx)
|
||||||
{
|
{
|
||||||
git_SHA1_Init_unsafe(&ctx->state.sha1_unsafe);
|
git_SHA1_Init_unsafe(&ctx->state.sha1_unsafe);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void git_hash_sha1_clone_unsafe(git_hash_ctx *dst, const git_hash_ctx *src)
|
static void git_hash_sha1_clone_unsafe(struct git_hash_ctx *dst, const struct git_hash_ctx *src)
|
||||||
{
|
{
|
||||||
git_SHA1_Clone_unsafe(&dst->state.sha1_unsafe, &src->state.sha1_unsafe);
|
git_SHA1_Clone_unsafe(&dst->state.sha1_unsafe, &src->state.sha1_unsafe);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void git_hash_sha1_update_unsafe(git_hash_ctx *ctx, const void *data,
|
static void git_hash_sha1_update_unsafe(struct git_hash_ctx *ctx, const void *data,
|
||||||
size_t len)
|
size_t len)
|
||||||
{
|
{
|
||||||
git_SHA1_Update_unsafe(&ctx->state.sha1_unsafe, data, len);
|
git_SHA1_Update_unsafe(&ctx->state.sha1_unsafe, data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void git_hash_sha1_final_unsafe(unsigned char *hash, git_hash_ctx *ctx)
|
static void git_hash_sha1_final_unsafe(unsigned char *hash, struct git_hash_ctx *ctx)
|
||||||
{
|
{
|
||||||
git_SHA1_Final_unsafe(hash, &ctx->state.sha1_unsafe);
|
git_SHA1_Final_unsafe(hash, &ctx->state.sha1_unsafe);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void git_hash_sha1_final_oid_unsafe(struct object_id *oid, git_hash_ctx *ctx)
|
static void git_hash_sha1_final_oid_unsafe(struct object_id *oid, struct git_hash_ctx *ctx)
|
||||||
{
|
{
|
||||||
git_SHA1_Final_unsafe(oid->hash, &ctx->state.sha1_unsafe);
|
git_SHA1_Final_unsafe(oid->hash, &ctx->state.sha1_unsafe);
|
||||||
memset(oid->hash + GIT_SHA1_RAWSZ, 0, GIT_MAX_RAWSZ - GIT_SHA1_RAWSZ);
|
memset(oid->hash + GIT_SHA1_RAWSZ, 0, GIT_MAX_RAWSZ - GIT_SHA1_RAWSZ);
|
||||||
oid->algo = GIT_HASH_SHA1;
|
oid->algo = GIT_HASH_SHA1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void git_hash_sha256_init(git_hash_ctx *ctx)
|
static void git_hash_sha256_init(struct git_hash_ctx *ctx)
|
||||||
{
|
{
|
||||||
git_SHA256_Init(&ctx->state.sha256);
|
git_SHA256_Init(&ctx->state.sha256);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void git_hash_sha256_clone(git_hash_ctx *dst, const git_hash_ctx *src)
|
static void git_hash_sha256_clone(struct git_hash_ctx *dst, const struct git_hash_ctx *src)
|
||||||
{
|
{
|
||||||
git_SHA256_Clone(&dst->state.sha256, &src->state.sha256);
|
git_SHA256_Clone(&dst->state.sha256, &src->state.sha256);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void git_hash_sha256_update(git_hash_ctx *ctx, const void *data, size_t len)
|
static void git_hash_sha256_update(struct git_hash_ctx *ctx, const void *data, size_t len)
|
||||||
{
|
{
|
||||||
git_SHA256_Update(&ctx->state.sha256, data, len);
|
git_SHA256_Update(&ctx->state.sha256, data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void git_hash_sha256_final(unsigned char *hash, git_hash_ctx *ctx)
|
static void git_hash_sha256_final(unsigned char *hash, struct git_hash_ctx *ctx)
|
||||||
{
|
{
|
||||||
git_SHA256_Final(hash, &ctx->state.sha256);
|
git_SHA256_Final(hash, &ctx->state.sha256);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void git_hash_sha256_final_oid(struct object_id *oid, git_hash_ctx *ctx)
|
static void git_hash_sha256_final_oid(struct object_id *oid, struct git_hash_ctx *ctx)
|
||||||
{
|
{
|
||||||
git_SHA256_Final(oid->hash, &ctx->state.sha256);
|
git_SHA256_Final(oid->hash, &ctx->state.sha256);
|
||||||
/*
|
/*
|
||||||
|
|
@ -172,18 +172,18 @@ static void git_hash_sha256_final_oid(struct object_id *oid, git_hash_ctx *ctx)
|
||||||
oid->algo = GIT_HASH_SHA256;
|
oid->algo = GIT_HASH_SHA256;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void git_hash_unknown_init(git_hash_ctx *ctx UNUSED)
|
static void git_hash_unknown_init(struct git_hash_ctx *ctx UNUSED)
|
||||||
{
|
{
|
||||||
BUG("trying to init unknown hash");
|
BUG("trying to init unknown hash");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void git_hash_unknown_clone(git_hash_ctx *dst UNUSED,
|
static void git_hash_unknown_clone(struct git_hash_ctx *dst UNUSED,
|
||||||
const git_hash_ctx *src UNUSED)
|
const struct git_hash_ctx *src UNUSED)
|
||||||
{
|
{
|
||||||
BUG("trying to clone unknown hash");
|
BUG("trying to clone unknown hash");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void git_hash_unknown_update(git_hash_ctx *ctx UNUSED,
|
static void git_hash_unknown_update(struct git_hash_ctx *ctx UNUSED,
|
||||||
const void *data UNUSED,
|
const void *data UNUSED,
|
||||||
size_t len UNUSED)
|
size_t len UNUSED)
|
||||||
{
|
{
|
||||||
|
|
@ -191,13 +191,13 @@ static void git_hash_unknown_update(git_hash_ctx *ctx UNUSED,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void git_hash_unknown_final(unsigned char *hash UNUSED,
|
static void git_hash_unknown_final(unsigned char *hash UNUSED,
|
||||||
git_hash_ctx *ctx UNUSED)
|
struct git_hash_ctx *ctx UNUSED)
|
||||||
{
|
{
|
||||||
BUG("trying to finalize unknown hash");
|
BUG("trying to finalize unknown hash");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void git_hash_unknown_final_oid(struct object_id *oid UNUSED,
|
static void git_hash_unknown_final_oid(struct object_id *oid UNUSED,
|
||||||
git_hash_ctx *ctx UNUSED)
|
struct git_hash_ctx *ctx UNUSED)
|
||||||
{
|
{
|
||||||
BUG("trying to finalize unknown hash");
|
BUG("trying to finalize unknown hash");
|
||||||
}
|
}
|
||||||
|
|
@ -1180,7 +1180,7 @@ int stream_object_signature(struct repository *r, const struct object_id *oid)
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
enum object_type obj_type;
|
enum object_type obj_type;
|
||||||
struct git_istream *st;
|
struct git_istream *st;
|
||||||
git_hash_ctx c;
|
struct git_hash_ctx c;
|
||||||
char hdr[MAX_HEADER_LEN];
|
char hdr[MAX_HEADER_LEN];
|
||||||
int hdrlen;
|
int hdrlen;
|
||||||
|
|
||||||
|
|
@ -1945,7 +1945,7 @@ void *read_object_with_reference(struct repository *r,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hash_object_body(const struct git_hash_algo *algo, git_hash_ctx *c,
|
static void hash_object_body(const struct git_hash_algo *algo, struct git_hash_ctx *c,
|
||||||
const void *buf, unsigned long len,
|
const void *buf, unsigned long len,
|
||||||
struct object_id *oid,
|
struct object_id *oid,
|
||||||
char *hdr, int *hdrlen)
|
char *hdr, int *hdrlen)
|
||||||
|
|
@ -1961,7 +1961,7 @@ static void write_object_file_prepare(const struct git_hash_algo *algo,
|
||||||
enum object_type type, struct object_id *oid,
|
enum object_type type, struct object_id *oid,
|
||||||
char *hdr, int *hdrlen)
|
char *hdr, int *hdrlen)
|
||||||
{
|
{
|
||||||
git_hash_ctx c;
|
struct git_hash_ctx c;
|
||||||
|
|
||||||
/* Generate the header */
|
/* Generate the header */
|
||||||
*hdrlen = format_object_header(hdr, *hdrlen, type, len);
|
*hdrlen = format_object_header(hdr, *hdrlen, type, len);
|
||||||
|
|
@ -1975,7 +1975,7 @@ static void write_object_file_prepare_literally(const struct git_hash_algo *algo
|
||||||
const char *type, struct object_id *oid,
|
const char *type, struct object_id *oid,
|
||||||
char *hdr, int *hdrlen)
|
char *hdr, int *hdrlen)
|
||||||
{
|
{
|
||||||
git_hash_ctx c;
|
struct git_hash_ctx c;
|
||||||
|
|
||||||
*hdrlen = format_object_header_literally(hdr, *hdrlen, type, len);
|
*hdrlen = format_object_header_literally(hdr, *hdrlen, type, len);
|
||||||
hash_object_body(algo, &c, buf, len, oid, hdr, hdrlen);
|
hash_object_body(algo, &c, buf, len, oid, hdr, hdrlen);
|
||||||
|
|
@ -2206,7 +2206,7 @@ static int start_loose_object_common(struct strbuf *tmp_file,
|
||||||
const char *filename, unsigned flags,
|
const char *filename, unsigned flags,
|
||||||
git_zstream *stream,
|
git_zstream *stream,
|
||||||
unsigned char *buf, size_t buflen,
|
unsigned char *buf, size_t buflen,
|
||||||
git_hash_ctx *c, git_hash_ctx *compat_c,
|
struct git_hash_ctx *c, struct git_hash_ctx *compat_c,
|
||||||
char *hdr, int hdrlen)
|
char *hdr, int hdrlen)
|
||||||
{
|
{
|
||||||
struct repository *repo = the_repository;
|
struct repository *repo = the_repository;
|
||||||
|
|
@ -2251,7 +2251,7 @@ static int start_loose_object_common(struct strbuf *tmp_file,
|
||||||
* Common steps for the inner git_deflate() loop for writing loose
|
* Common steps for the inner git_deflate() loop for writing loose
|
||||||
* objects. Returns what git_deflate() returns.
|
* objects. Returns what git_deflate() returns.
|
||||||
*/
|
*/
|
||||||
static int write_loose_object_common(git_hash_ctx *c, git_hash_ctx *compat_c,
|
static int write_loose_object_common(struct git_hash_ctx *c, struct git_hash_ctx *compat_c,
|
||||||
git_zstream *stream, const int flush,
|
git_zstream *stream, const int flush,
|
||||||
unsigned char *in0, const int fd,
|
unsigned char *in0, const int fd,
|
||||||
unsigned char *compressed,
|
unsigned char *compressed,
|
||||||
|
|
@ -2280,7 +2280,7 @@ static int write_loose_object_common(git_hash_ctx *c, git_hash_ctx *compat_c,
|
||||||
* - End the compression of zlib stream.
|
* - End the compression of zlib stream.
|
||||||
* - Get the calculated oid to "oid".
|
* - Get the calculated oid to "oid".
|
||||||
*/
|
*/
|
||||||
static int end_loose_object_common(git_hash_ctx *c, git_hash_ctx *compat_c,
|
static int end_loose_object_common(struct git_hash_ctx *c, struct git_hash_ctx *compat_c,
|
||||||
git_zstream *stream, struct object_id *oid,
|
git_zstream *stream, struct object_id *oid,
|
||||||
struct object_id *compat_oid)
|
struct object_id *compat_oid)
|
||||||
{
|
{
|
||||||
|
|
@ -2306,7 +2306,7 @@ static int write_loose_object(const struct object_id *oid, char *hdr,
|
||||||
int fd, ret;
|
int fd, ret;
|
||||||
unsigned char compressed[4096];
|
unsigned char compressed[4096];
|
||||||
git_zstream stream;
|
git_zstream stream;
|
||||||
git_hash_ctx c;
|
struct git_hash_ctx c;
|
||||||
struct object_id parano_oid;
|
struct object_id parano_oid;
|
||||||
static struct strbuf tmp_file = STRBUF_INIT;
|
static struct strbuf tmp_file = STRBUF_INIT;
|
||||||
static struct strbuf filename = STRBUF_INIT;
|
static struct strbuf filename = STRBUF_INIT;
|
||||||
|
|
@ -2386,7 +2386,7 @@ int stream_loose_object(struct input_stream *in_stream, size_t len,
|
||||||
int fd, ret, err = 0, flush = 0;
|
int fd, ret, err = 0, flush = 0;
|
||||||
unsigned char compressed[4096];
|
unsigned char compressed[4096];
|
||||||
git_zstream stream;
|
git_zstream stream;
|
||||||
git_hash_ctx c, compat_c;
|
struct git_hash_ctx c, compat_c;
|
||||||
struct strbuf tmp_file = STRBUF_INIT;
|
struct strbuf tmp_file = STRBUF_INIT;
|
||||||
struct strbuf filename = STRBUF_INIT;
|
struct strbuf filename = STRBUF_INIT;
|
||||||
int dirlen;
|
int dirlen;
|
||||||
|
|
@ -3046,7 +3046,7 @@ static int check_stream_oid(git_zstream *stream,
|
||||||
const char *path,
|
const char *path,
|
||||||
const struct object_id *expected_oid)
|
const struct object_id *expected_oid)
|
||||||
{
|
{
|
||||||
git_hash_ctx c;
|
struct git_hash_ctx c;
|
||||||
struct object_id real_oid;
|
struct object_id real_oid;
|
||||||
unsigned char buf[4096];
|
unsigned char buf[4096];
|
||||||
unsigned long total_read;
|
unsigned long total_read;
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ static int verify_packfile(struct repository *r,
|
||||||
{
|
{
|
||||||
off_t index_size = p->index_size;
|
off_t index_size = p->index_size;
|
||||||
const unsigned char *index_base = p->index_data;
|
const unsigned char *index_base = p->index_data;
|
||||||
git_hash_ctx ctx;
|
struct git_hash_ctx ctx;
|
||||||
unsigned char hash[GIT_MAX_RAWSZ], *pack_sig;
|
unsigned char hash[GIT_MAX_RAWSZ], *pack_sig;
|
||||||
off_t offset = 0, pack_sig_ofs = 0;
|
off_t offset = 0, pack_sig_ofs = 0;
|
||||||
uint32_t nr_objects, i;
|
uint32_t nr_objects, i;
|
||||||
|
|
|
||||||
|
|
@ -388,7 +388,7 @@ void fixup_pack_header_footer(int pack_fd,
|
||||||
off_t partial_pack_offset)
|
off_t partial_pack_offset)
|
||||||
{
|
{
|
||||||
int aligned_sz, buf_sz = 8 * 1024;
|
int aligned_sz, buf_sz = 8 * 1024;
|
||||||
git_hash_ctx old_hash_ctx, new_hash_ctx;
|
struct git_hash_ctx old_hash_ctx, new_hash_ctx;
|
||||||
struct pack_header hdr;
|
struct pack_header hdr;
|
||||||
char *buf;
|
char *buf;
|
||||||
ssize_t read_result;
|
ssize_t read_result;
|
||||||
|
|
|
||||||
12
read-cache.c
12
read-cache.c
|
|
@ -1717,7 +1717,7 @@ int verify_ce_order;
|
||||||
|
|
||||||
static int verify_hdr(const struct cache_header *hdr, unsigned long size)
|
static int verify_hdr(const struct cache_header *hdr, unsigned long size)
|
||||||
{
|
{
|
||||||
git_hash_ctx c;
|
struct git_hash_ctx c;
|
||||||
unsigned char hash[GIT_MAX_RAWSZ];
|
unsigned char hash[GIT_MAX_RAWSZ];
|
||||||
int hdr_version;
|
int hdr_version;
|
||||||
unsigned char *start, *end;
|
unsigned char *start, *end;
|
||||||
|
|
@ -2002,7 +2002,7 @@ static struct index_entry_offset_table *read_ieot_extension(const char *mmap, si
|
||||||
static void write_ieot_extension(struct strbuf *sb, struct index_entry_offset_table *ieot);
|
static void write_ieot_extension(struct strbuf *sb, struct index_entry_offset_table *ieot);
|
||||||
|
|
||||||
static size_t read_eoie_extension(const char *mmap, size_t mmap_size);
|
static size_t read_eoie_extension(const char *mmap, size_t mmap_size);
|
||||||
static void write_eoie_extension(struct strbuf *sb, git_hash_ctx *eoie_context, size_t offset);
|
static void write_eoie_extension(struct strbuf *sb, struct git_hash_ctx *eoie_context, size_t offset);
|
||||||
|
|
||||||
struct load_index_extensions
|
struct load_index_extensions
|
||||||
{
|
{
|
||||||
|
|
@ -2566,7 +2566,7 @@ int repo_index_has_changes(struct repository *repo,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int write_index_ext_header(struct hashfile *f,
|
static int write_index_ext_header(struct hashfile *f,
|
||||||
git_hash_ctx *eoie_f,
|
struct git_hash_ctx *eoie_f,
|
||||||
unsigned int ext,
|
unsigned int ext,
|
||||||
unsigned int sz)
|
unsigned int sz)
|
||||||
{
|
{
|
||||||
|
|
@ -2831,7 +2831,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
|
||||||
{
|
{
|
||||||
uint64_t start = getnanotime();
|
uint64_t start = getnanotime();
|
||||||
struct hashfile *f;
|
struct hashfile *f;
|
||||||
git_hash_ctx *eoie_c = NULL;
|
struct git_hash_ctx *eoie_c = NULL;
|
||||||
struct cache_header hdr;
|
struct cache_header hdr;
|
||||||
int i, err = 0, removed, extended, hdr_version;
|
int i, err = 0, removed, extended, hdr_version;
|
||||||
struct cache_entry **cache = istate->cache;
|
struct cache_entry **cache = istate->cache;
|
||||||
|
|
@ -3579,7 +3579,7 @@ static size_t read_eoie_extension(const char *mmap, size_t mmap_size)
|
||||||
uint32_t extsize;
|
uint32_t extsize;
|
||||||
size_t offset, src_offset;
|
size_t offset, src_offset;
|
||||||
unsigned char hash[GIT_MAX_RAWSZ];
|
unsigned char hash[GIT_MAX_RAWSZ];
|
||||||
git_hash_ctx c;
|
struct git_hash_ctx c;
|
||||||
|
|
||||||
/* ensure we have an index big enough to contain an EOIE extension */
|
/* ensure we have an index big enough to contain an EOIE extension */
|
||||||
if (mmap_size < sizeof(struct cache_header) + EOIE_SIZE_WITH_HEADER + the_hash_algo->rawsz)
|
if (mmap_size < sizeof(struct cache_header) + EOIE_SIZE_WITH_HEADER + the_hash_algo->rawsz)
|
||||||
|
|
@ -3650,7 +3650,7 @@ static size_t read_eoie_extension(const char *mmap, size_t mmap_size)
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_eoie_extension(struct strbuf *sb, git_hash_ctx *eoie_context, size_t offset)
|
static void write_eoie_extension(struct strbuf *sb, struct git_hash_ctx *eoie_context, size_t offset)
|
||||||
{
|
{
|
||||||
uint32_t buffer;
|
uint32_t buffer;
|
||||||
unsigned char hash[GIT_MAX_RAWSZ];
|
unsigned char hash[GIT_MAX_RAWSZ];
|
||||||
|
|
|
||||||
4
rerere.c
4
rerere.c
|
|
@ -358,7 +358,7 @@ static void rerere_strbuf_putconflict(struct strbuf *buf, int ch, size_t size)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handle_conflict(struct strbuf *out, struct rerere_io *io,
|
static int handle_conflict(struct strbuf *out, struct rerere_io *io,
|
||||||
int marker_size, git_hash_ctx *ctx)
|
int marker_size, struct git_hash_ctx *ctx)
|
||||||
{
|
{
|
||||||
enum {
|
enum {
|
||||||
RR_SIDE_1 = 0, RR_SIDE_2, RR_ORIGINAL
|
RR_SIDE_1 = 0, RR_SIDE_2, RR_ORIGINAL
|
||||||
|
|
@ -432,7 +432,7 @@ static int handle_conflict(struct strbuf *out, struct rerere_io *io,
|
||||||
*/
|
*/
|
||||||
static int handle_path(unsigned char *hash, struct rerere_io *io, int marker_size)
|
static int handle_path(unsigned char *hash, struct rerere_io *io, int marker_size)
|
||||||
{
|
{
|
||||||
git_hash_ctx ctx;
|
struct git_hash_ctx ctx;
|
||||||
struct strbuf buf = STRBUF_INIT, out = STRBUF_INIT;
|
struct strbuf buf = STRBUF_INIT, out = STRBUF_INIT;
|
||||||
int has_conflicts = 0;
|
int has_conflicts = 0;
|
||||||
if (hash)
|
if (hash)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#define NUM_SECONDS 3
|
#define NUM_SECONDS 3
|
||||||
|
|
||||||
static inline void compute_hash(const struct git_hash_algo *algo, git_hash_ctx *ctx, uint8_t *final, const void *p, size_t len)
|
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);
|
algo->init_fn(ctx);
|
||||||
algo->update_fn(ctx, p, len);
|
algo->update_fn(ctx, p, len);
|
||||||
|
|
@ -12,7 +12,7 @@ static inline void compute_hash(const struct git_hash_algo *algo, git_hash_ctx *
|
||||||
|
|
||||||
int cmd__hash_speed(int ac, const char **av)
|
int cmd__hash_speed(int ac, const char **av)
|
||||||
{
|
{
|
||||||
git_hash_ctx ctx;
|
struct git_hash_ctx ctx;
|
||||||
unsigned char hash[GIT_MAX_RAWSZ];
|
unsigned char hash[GIT_MAX_RAWSZ];
|
||||||
clock_t initial, start, end;
|
clock_t initial, start, end;
|
||||||
unsigned bufsizes[] = { 64, 256, 1024, 8192, 16384 };
|
unsigned bufsizes[] = { 64, 256, 1024, 8192, 16384 };
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
int cmd_hash_impl(int ac, const char **av, int algo, int unsafe)
|
int cmd_hash_impl(int ac, const char **av, int algo, int unsafe)
|
||||||
{
|
{
|
||||||
git_hash_ctx ctx;
|
struct git_hash_ctx ctx;
|
||||||
unsigned char hash[GIT_MAX_HEXSZ];
|
unsigned char hash[GIT_MAX_HEXSZ];
|
||||||
unsigned bufsz = 8192;
|
unsigned bufsz = 8192;
|
||||||
int binary = 0;
|
int binary = 0;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ static void check_hash_data(const void *data, size_t data_length,
|
||||||
cl_assert(data != NULL);
|
cl_assert(data != NULL);
|
||||||
|
|
||||||
for (size_t i = 1; i < ARRAY_SIZE(hash_algos); i++) {
|
for (size_t i = 1; i < ARRAY_SIZE(hash_algos); i++) {
|
||||||
git_hash_ctx ctx;
|
struct git_hash_ctx ctx;
|
||||||
unsigned char hash[GIT_MAX_HEXSZ];
|
unsigned char hash[GIT_MAX_HEXSZ];
|
||||||
const struct git_hash_algo *algop = &hash_algos[i];
|
const struct git_hash_algo *algop = &hash_algos[i];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ static void tr2_sid_append_my_sid_component(void)
|
||||||
{
|
{
|
||||||
const struct git_hash_algo *algo = &hash_algos[GIT_HASH_SHA1];
|
const struct git_hash_algo *algo = &hash_algos[GIT_HASH_SHA1];
|
||||||
struct tr2_tbuf tb_now;
|
struct tr2_tbuf tb_now;
|
||||||
git_hash_ctx ctx;
|
struct git_hash_ctx ctx;
|
||||||
pid_t pid = getpid();
|
pid_t pid = getpid();
|
||||||
unsigned char hash[GIT_MAX_RAWSZ + 1];
|
unsigned char hash[GIT_MAX_RAWSZ + 1];
|
||||||
char hex[GIT_MAX_HEXSZ + 1];
|
char hex[GIT_MAX_HEXSZ + 1];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue