Skip to content

Commit 9bab081

Browse files
szedergitster
authored andcommitted
commit-graph: unify the signatures of all write_graph_chunk_*() functions
Update the write_graph_chunk_*() helper functions to have the same signature: - Return an int error code from all these functions. write_graph_chunk_base() already has an int error code, now the others will have one, too, but since they don't indicate any error, they will always return 0. - Drop the hash size parameter of write_graph_chunk_oids() and write_graph_chunk_data(); its value can be read directly from 'the_hash_algo' inside these functions as well. This opens up the possibility for further cleanups and foolproofing in the following two patches. Helped-by: René Scharfe <[email protected]> Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0087a87 commit 9bab081

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

commit-graph.c

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -891,8 +891,8 @@ struct write_commit_graph_context {
891891
const struct bloom_filter_settings *bloom_settings;
892892
};
893893

894-
static void write_graph_chunk_fanout(struct hashfile *f,
895-
struct write_commit_graph_context *ctx)
894+
static int write_graph_chunk_fanout(struct hashfile *f,
895+
struct write_commit_graph_context *ctx)
896896
{
897897
int i, count = 0;
898898
struct commit **list = ctx->commits.list;
@@ -913,17 +913,21 @@ static void write_graph_chunk_fanout(struct hashfile *f,
913913

914914
hashwrite_be32(f, count);
915915
}
916+
917+
return 0;
916918
}
917919

918-
static void write_graph_chunk_oids(struct hashfile *f, int hash_len,
919-
struct write_commit_graph_context *ctx)
920+
static int write_graph_chunk_oids(struct hashfile *f,
921+
struct write_commit_graph_context *ctx)
920922
{
921923
struct commit **list = ctx->commits.list;
922924
int count;
923925
for (count = 0; count < ctx->commits.nr; count++, list++) {
924926
display_progress(ctx->progress, ++ctx->progress_cnt);
925-
hashwrite(f, (*list)->object.oid.hash, (int)hash_len);
927+
hashwrite(f, (*list)->object.oid.hash, the_hash_algo->rawsz);
926928
}
929+
930+
return 0;
927931
}
928932

929933
static const unsigned char *commit_to_sha1(size_t index, void *table)
@@ -932,8 +936,8 @@ static const unsigned char *commit_to_sha1(size_t index, void *table)
932936
return commits[index]->object.oid.hash;
933937
}
934938

935-
static void write_graph_chunk_data(struct hashfile *f, int hash_len,
936-
struct write_commit_graph_context *ctx)
939+
static int write_graph_chunk_data(struct hashfile *f,
940+
struct write_commit_graph_context *ctx)
937941
{
938942
struct commit **list = ctx->commits.list;
939943
struct commit **last = ctx->commits.list + ctx->commits.nr;
@@ -950,7 +954,7 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,
950954
die(_("unable to parse commit %s"),
951955
oid_to_hex(&(*list)->object.oid));
952956
tree = get_commit_tree_oid(*list);
953-
hashwrite(f, tree->hash, hash_len);
957+
hashwrite(f, tree->hash, the_hash_algo->rawsz);
954958

955959
parent = (*list)->parents;
956960

@@ -1030,10 +1034,12 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,
10301034

10311035
list++;
10321036
}
1037+
1038+
return 0;
10331039
}
10341040

1035-
static void write_graph_chunk_extra_edges(struct hashfile *f,
1036-
struct write_commit_graph_context *ctx)
1041+
static int write_graph_chunk_extra_edges(struct hashfile *f,
1042+
struct write_commit_graph_context *ctx)
10371043
{
10381044
struct commit **list = ctx->commits.list;
10391045
struct commit **last = ctx->commits.list + ctx->commits.nr;
@@ -1082,10 +1088,12 @@ static void write_graph_chunk_extra_edges(struct hashfile *f,
10821088

10831089
list++;
10841090
}
1091+
1092+
return 0;
10851093
}
10861094

1087-
static void write_graph_chunk_bloom_indexes(struct hashfile *f,
1088-
struct write_commit_graph_context *ctx)
1095+
static int write_graph_chunk_bloom_indexes(struct hashfile *f,
1096+
struct write_commit_graph_context *ctx)
10891097
{
10901098
struct commit **list = ctx->commits.list;
10911099
struct commit **last = ctx->commits.list + ctx->commits.nr;
@@ -1108,6 +1116,7 @@ static void write_graph_chunk_bloom_indexes(struct hashfile *f,
11081116
}
11091117

11101118
stop_progress(&progress);
1119+
return 0;
11111120
}
11121121

11131122
static void trace2_bloom_filter_settings(struct write_commit_graph_context *ctx)
@@ -1125,8 +1134,8 @@ static void trace2_bloom_filter_settings(struct write_commit_graph_context *ctx)
11251134
jw_release(&jw);
11261135
}
11271136

1128-
static void write_graph_chunk_bloom_data(struct hashfile *f,
1129-
struct write_commit_graph_context *ctx)
1137+
static int write_graph_chunk_bloom_data(struct hashfile *f,
1138+
struct write_commit_graph_context *ctx)
11301139
{
11311140
struct commit **list = ctx->commits.list;
11321141
struct commit **last = ctx->commits.list + ctx->commits.nr;
@@ -1155,6 +1164,7 @@ static void write_graph_chunk_bloom_data(struct hashfile *f,
11551164
}
11561165

11571166
stop_progress(&progress);
1167+
return 0;
11581168
}
11591169

11601170
static int oid_compare(const void *_a, const void *_b)
@@ -1671,8 +1681,8 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
16711681
num_chunks * ctx->commits.nr);
16721682
}
16731683
write_graph_chunk_fanout(f, ctx);
1674-
write_graph_chunk_oids(f, hashsz, ctx);
1675-
write_graph_chunk_data(f, hashsz, ctx);
1684+
write_graph_chunk_oids(f, ctx);
1685+
write_graph_chunk_data(f, ctx);
16761686
if (ctx->num_extra_edges)
16771687
write_graph_chunk_extra_edges(f, ctx);
16781688
if (ctx->changed_paths) {

0 commit comments

Comments
 (0)