Skip to content

Commit 7346e34

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 52eef50 commit 7346e34

22 files changed

+73
-74
lines changed

builtin/fast-import.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ static int store_object(
953953
unsigned char hdr[96];
954954
struct object_id oid;
955955
unsigned long hdrlen, deltalen;
956-
git_hash_ctx c;
956+
struct git_hash_ctx c;
957957
git_zstream s;
958958

959959
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)
10951095
struct object_id oid;
10961096
unsigned long hdrlen;
10971097
off_t offset;
1098-
git_hash_ctx c;
1098+
struct git_hash_ctx c;
10991099
git_zstream s;
11001100
struct hashfile_checkpoint checkpoint;
11011101
int status = Z_OK;

builtin/index-pack.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static unsigned int input_offset, input_len;
151151
static off_t consumed_bytes;
152152
static off_t max_input_size;
153153
static unsigned deepest_delta;
154-
static git_hash_ctx input_ctx;
154+
static struct git_hash_ctx input_ctx;
155155
static uint32_t input_crc32;
156156
static int input_fd, output_fd;
157157
static const char *curr_pack;
@@ -475,7 +475,7 @@ static void *unpack_entry_data(off_t offset, unsigned long size,
475475
int status;
476476
git_zstream stream;
477477
void *buf;
478-
git_hash_ctx c;
478+
struct git_hash_ctx c;
479479
char hdr[32];
480480
int hdrlen;
481481

@@ -1248,7 +1248,7 @@ static void parse_pack_objects(unsigned char *hash)
12481248
struct ofs_delta_entry *ofs_delta = ofs_deltas;
12491249
struct object_id ref_delta_oid;
12501250
struct stat st;
1251-
git_hash_ctx tmp_ctx;
1251+
struct git_hash_ctx tmp_ctx;
12521252

12531253
if (verbose)
12541254
progress = start_progress(

builtin/patch-id.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static size_t get_one_patchid(struct object_id *next_oid, struct object_id *resu
7070
int before = -1, after = -1;
7171
int diff_is_binary = 0;
7272
char pre_oid_str[GIT_MAX_HEXSZ + 1], post_oid_str[GIT_MAX_HEXSZ + 1];
73-
git_hash_ctx ctx;
73+
struct git_hash_ctx ctx;
7474

7575
the_hash_algo->init_fn(&ctx);
7676
oidclr(result, the_repository->hash_algo);

builtin/receive-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ static void hmac_hash(unsigned char *out,
566566
unsigned char k_ipad[GIT_MAX_BLKSZ];
567567
unsigned char k_opad[GIT_MAX_BLKSZ];
568568
int i;
569-
git_hash_ctx ctx;
569+
struct git_hash_ctx ctx;
570570

571571
/* RFC 2104 2. (1) */
572572
memset(key, '\0', GIT_MAX_BLKSZ);

builtin/unpack-objects.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static unsigned char buffer[4096];
2828
static unsigned int offset, len;
2929
static off_t consumed_bytes;
3030
static off_t max_input_size;
31-
static git_hash_ctx ctx;
31+
static struct git_hash_ctx ctx;
3232
static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;
3333
static struct progress *progress;
3434

@@ -614,7 +614,7 @@ int cmd_unpack_objects(int argc,
614614
{
615615
int i;
616616
struct object_id oid;
617-
git_hash_ctx tmp_ctx;
617+
struct git_hash_ctx tmp_ctx;
618618

619619
disable_replace_refs();
620620

bulk-checkin.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static int already_written(struct bulk_checkin_packfile *state, struct object_id
161161
* with a new pack.
162162
*/
163163
static int stream_blob_to_pack(struct bulk_checkin_packfile *state,
164-
git_hash_ctx *ctx, off_t *already_hashed_to,
164+
struct git_hash_ctx *ctx, off_t *already_hashed_to,
165165
int fd, size_t size, const char *path,
166166
unsigned flags)
167167
{
@@ -258,7 +258,7 @@ static int deflate_blob_to_pack(struct bulk_checkin_packfile *state,
258258
const char *path, unsigned flags)
259259
{
260260
off_t seekback, already_hashed_to;
261-
git_hash_ctx ctx;
261+
struct git_hash_ctx ctx;
262262
unsigned char obuf[16384];
263263
unsigned header_len;
264264
struct hashfile_checkpoint checkpoint;

csum-file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ uint32_t crc32_end(struct hashfile *f)
248248
int hashfile_checksum_valid(const unsigned char *data, size_t total_len)
249249
{
250250
unsigned char got[GIT_MAX_RAWSZ];
251-
git_hash_ctx ctx;
251+
struct git_hash_ctx ctx;
252252
const struct git_hash_algo *algop = unsafe_hash_algo(the_hash_algo);
253253
size_t data_len = total_len - algop->rawsz;
254254

csum-file.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct hashfile {
1111
int fd;
1212
int check_fd;
1313
unsigned int offset;
14-
git_hash_ctx ctx;
14+
struct git_hash_ctx ctx;
1515
off_t total;
1616
struct progress *tp;
1717
const char *name;
@@ -33,7 +33,7 @@ struct hashfile {
3333
/* Checkpoint */
3434
struct hashfile_checkpoint {
3535
off_t offset;
36-
git_hash_ctx ctx;
36+
struct git_hash_ctx ctx;
3737
};
3838

3939
void hashfile_checkpoint_init(struct hashfile *, struct hashfile_checkpoint *);

diff.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6392,7 +6392,7 @@ static void diff_summary(struct diff_options *opt, struct diff_filepair *p)
63926392
}
63936393

63946394
struct patch_id_t {
6395-
git_hash_ctx *ctx;
6395+
struct git_hash_ctx *ctx;
63966396
int patchlen;
63976397
};
63986398

@@ -6409,7 +6409,7 @@ static int remove_space(char *line, int len)
64096409
return dst - line;
64106410
}
64116411

6412-
void flush_one_hunk(struct object_id *result, git_hash_ctx *ctx)
6412+
void flush_one_hunk(struct object_id *result, struct git_hash_ctx *ctx)
64136413
{
64146414
unsigned char hash[GIT_MAX_RAWSZ];
64156415
unsigned short carry = 0;
@@ -6439,12 +6439,12 @@ static int patch_id_consume(void *priv, char *line, unsigned long len)
64396439
return 0;
64406440
}
64416441

6442-
static void patch_id_add_string(git_hash_ctx *ctx, const char *str)
6442+
static void patch_id_add_string(struct git_hash_ctx *ctx, const char *str)
64436443
{
64446444
the_hash_algo->update_fn(ctx, str, strlen(str));
64456445
}
64466446

6447-
static void patch_id_add_mode(git_hash_ctx *ctx, unsigned mode)
6447+
static void patch_id_add_mode(struct git_hash_ctx *ctx, unsigned mode)
64486448
{
64496449
/* large enough for 2^32 in octal */
64506450
char buf[12];
@@ -6457,7 +6457,7 @@ static int diff_get_patch_id(struct diff_options *options, struct object_id *oid
64576457
{
64586458
struct diff_queue_struct *q = &diff_queued_diff;
64596459
int i;
6460-
git_hash_ctx ctx;
6460+
struct git_hash_ctx ctx;
64616461
struct patch_id_t data;
64626462

64636463
the_hash_algo->init_fn(&ctx);

diff.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ void run_diff_index(struct rev_info *revs, unsigned int option);
644644

645645
int do_diff_cache(const struct object_id *, struct diff_options *);
646646
int diff_flush_patch_id(struct diff_options *, struct object_id *, int);
647-
void flush_one_hunk(struct object_id *result, git_hash_ctx *ctx);
647+
void flush_one_hunk(struct object_id *result, struct git_hash_ctx *ctx);
648648

649649
int diff_result_code(struct rev_info *);
650650

0 commit comments

Comments
 (0)