Re: [PATCH 2/8] commit-graph: unify the signatures of all write_graph_chunk_*() functions
- From
René Scharfe <l.s.r@web.de>
- Date
- Jun 18, 2020, 20:30 UTC
- Message-ID
- <1e0c501e-3d2d-55b2-431a-f6760a184a80@web.de>
- In-Reply-To
- <65eb15221c8d3b631d6d7105d0e901433bc7f23b.1592252093.git.gitgitgadget@gmail.com>
Am 15.06.20 um 22:14 schrieb SZEDER Gábor via GitGitGadget:
Show 11 quoted lines
> -static void write_graph_chunk_oids(struct hashfile *f, int hash_len,
> - struct write_commit_graph_context *ctx)
> +static int write_graph_chunk_oids(struct hashfile *f,
> + struct write_commit_graph_context *ctx)
> {
> struct commit **list = ctx->commits.list;
> int count;
> for (count = 0; count < ctx->commits.nr; count++, list++) {
> display_progress(ctx->progress, ++ctx->progress_cnt);
> - hashwrite(f, (*list)->object.oid.hash, (int)hash_len);
> + hashwrite(f, (*list)->object.oid.hash, (int)the_hash_algo->rawsz);Before the cast was forcing an int into an int (huh?), now it forces a size_t into an int, but hashwrite() expects an unsigned int. Do we really need that cast?
Show 23 quoted lines
> }
> +
> + return 0;
> }
>
> static const unsigned char *commit_to_sha1(size_t index, void *table)
> @@ -926,8 +930,8 @@ static const unsigned char *commit_to_sha1(size_t index, void *table)
> return commits[index]->object.oid.hash;
> }
>
> -static void write_graph_chunk_data(struct hashfile *f, int hash_len,
> - struct write_commit_graph_context *ctx)
> +static int write_graph_chunk_data(struct hashfile *f,
> + struct write_commit_graph_context *ctx)
> {
> struct commit **list = ctx->commits.list;
> struct commit **last = ctx->commits.list + ctx->commits.nr;
> @@ -944,7 +948,7 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,
> die(_("unable to parse commit %s"),
> oid_to_hex(&(*list)->object.oid));
> tree = get_commit_tree_oid(*list);
> - hashwrite(f, tree->hash, hash_len);
> + hashwrite(f, tree->hash, the_hash_algo->rawsz);... and here's the answer: No, we don't need to cast.
René