Skip to content

Commit 65eb152

Browse files
szederderrickstolee
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. Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Derrick Stolee <[email protected]>
1 parent c966969 commit 65eb152

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
@@ -885,8 +885,8 @@ struct write_commit_graph_context {
885885
struct bloom_filter_settings bloom_settings;
886886
};
887887

888-
static void write_graph_chunk_fanout(struct hashfile *f,
889-
struct write_commit_graph_context *ctx)
888+
static int write_graph_chunk_fanout(struct hashfile *f,
889+
struct write_commit_graph_context *ctx)
890890
{
891891
int i, count = 0;
892892
struct commit **list = ctx->commits.list;
@@ -907,17 +907,21 @@ static void write_graph_chunk_fanout(struct hashfile *f,
907907

908908
hashwrite_be32(f, count);
909909
}
910+
911+
return 0;
910912
}
911913

912-
static void write_graph_chunk_oids(struct hashfile *f, int hash_len,
913-
struct write_commit_graph_context *ctx)
914+
static int write_graph_chunk_oids(struct hashfile *f,
915+
struct write_commit_graph_context *ctx)
914916
{
915917
struct commit **list = ctx->commits.list;
916918
int count;
917919
for (count = 0; count < ctx->commits.nr; count++, list++) {
918920
display_progress(ctx->progress, ++ctx->progress_cnt);
919-
hashwrite(f, (*list)->object.oid.hash, (int)hash_len);
921+
hashwrite(f, (*list)->object.oid.hash, (int)the_hash_algo->rawsz);
920922
}
923+
924+
return 0;
921925
}
922926

923927
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)
926930
return commits[index]->object.oid.hash;
927931
}
928932

929-
static void write_graph_chunk_data(struct hashfile *f, int hash_len,
930-
struct write_commit_graph_context *ctx)
933+
static int write_graph_chunk_data(struct hashfile *f,
934+
struct write_commit_graph_context *ctx)
931935
{
932936
struct commit **list = ctx->commits.list;
933937
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,
944948
die(_("unable to parse commit %s"),
945949
oid_to_hex(&(*list)->object.oid));
946950
tree = get_commit_tree_oid(*list);
947-
hashwrite(f, tree->hash, hash_len);
951+
hashwrite(f, tree->hash, the_hash_algo->rawsz);
948952

949953
parent = (*list)->parents;
950954

@@ -1024,10 +1028,12 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,
10241028

10251029
list++;
10261030
}
1031+
1032+
return 0;
10271033
}
10281034

1029-
static void write_graph_chunk_extra_edges(struct hashfile *f,
1030-
struct write_commit_graph_context *ctx)
1035+
static int write_graph_chunk_extra_edges(struct hashfile *f,
1036+
struct write_commit_graph_context *ctx)
10311037
{
10321038
struct commit **list = ctx->commits.list;
10331039
struct commit **last = ctx->commits.list + ctx->commits.nr;
@@ -1076,10 +1082,12 @@ static void write_graph_chunk_extra_edges(struct hashfile *f,
10761082

10771083
list++;
10781084
}
1085+
1086+
return 0;
10791087
}
10801088

1081-
static void write_graph_chunk_bloom_indexes(struct hashfile *f,
1082-
struct write_commit_graph_context *ctx)
1089+
static int write_graph_chunk_bloom_indexes(struct hashfile *f,
1090+
struct write_commit_graph_context *ctx)
10831091
{
10841092
struct commit **list = ctx->commits.list;
10851093
struct commit **last = ctx->commits.list + ctx->commits.nr;
@@ -1101,10 +1109,11 @@ static void write_graph_chunk_bloom_indexes(struct hashfile *f,
11011109
}
11021110

11031111
stop_progress(&progress);
1112+
return 0;
11041113
}
11051114

1106-
static void write_graph_chunk_bloom_data(struct hashfile *f,
1107-
struct write_commit_graph_context *ctx)
1115+
static int write_graph_chunk_bloom_data(struct hashfile *f,
1116+
struct write_commit_graph_context *ctx)
11081117
{
11091118
struct commit **list = ctx->commits.list;
11101119
struct commit **last = ctx->commits.list + ctx->commits.nr;
@@ -1128,6 +1137,7 @@ static void write_graph_chunk_bloom_data(struct hashfile *f,
11281137
}
11291138

11301139
stop_progress(&progress);
1140+
return 0;
11311141
}
11321142

11331143
static int oid_compare(const void *_a, const void *_b)
@@ -1638,8 +1648,8 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
16381648
num_chunks * ctx->commits.nr);
16391649
}
16401650
write_graph_chunk_fanout(f, ctx);
1641-
write_graph_chunk_oids(f, hashsz, ctx);
1642-
write_graph_chunk_data(f, hashsz, ctx);
1651+
write_graph_chunk_oids(f, ctx);
1652+
write_graph_chunk_data(f, ctx);
16431653
if (ctx->num_extra_edges)
16441654
write_graph_chunk_extra_edges(f, ctx);
16451655
if (ctx->changed_paths) {

0 commit comments

Comments
 (0)