Skip to content

Commit

Permalink
commit-graph: anonymize data in chunk_write_fn
Browse files Browse the repository at this point in the history
In preparation for creating an API around file formats using chunks and
tables of contents, prepare the commit-graph write code to use
prototypes that will match this new API.

Specifically, convert chunk_write_fn to take a "void *data" parameter
instead of the commit-graph-specific "struct write_commit_graph_context"
pointer.

Signed-off-by: Derrick Stolee <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
derrickstolee authored and gitster committed Feb 5, 2021
1 parent 5a3b130 commit eb90719
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions commit-graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -1040,8 +1040,9 @@ struct write_commit_graph_context {
};

static int write_graph_chunk_fanout(struct hashfile *f,
struct write_commit_graph_context *ctx)
void *data)
{
struct write_commit_graph_context *ctx = data;
int i, count = 0;
struct commit **list = ctx->commits.list;

Expand All @@ -1066,8 +1067,9 @@ static int write_graph_chunk_fanout(struct hashfile *f,
}

static int write_graph_chunk_oids(struct hashfile *f,
struct write_commit_graph_context *ctx)
void *data)
{
struct write_commit_graph_context *ctx = data;
struct commit **list = ctx->commits.list;
int count;
for (count = 0; count < ctx->commits.nr; count++, list++) {
Expand All @@ -1085,8 +1087,9 @@ static const unsigned char *commit_to_sha1(size_t index, void *table)
}

static int write_graph_chunk_data(struct hashfile *f,
struct write_commit_graph_context *ctx)
void *data)
{
struct write_commit_graph_context *ctx = data;
struct commit **list = ctx->commits.list;
struct commit **last = ctx->commits.list + ctx->commits.nr;
uint32_t num_extra_edges = 0;
Expand Down Expand Up @@ -1187,8 +1190,9 @@ static int write_graph_chunk_data(struct hashfile *f,
}

static int write_graph_chunk_generation_data(struct hashfile *f,
struct write_commit_graph_context *ctx)
void *data)
{
struct write_commit_graph_context *ctx = data;
int i, num_generation_data_overflows = 0;

for (i = 0; i < ctx->commits.nr; i++) {
Expand All @@ -1208,8 +1212,9 @@ static int write_graph_chunk_generation_data(struct hashfile *f,
}

static int write_graph_chunk_generation_data_overflow(struct hashfile *f,
struct write_commit_graph_context *ctx)
void *data)
{
struct write_commit_graph_context *ctx = data;
int i;
for (i = 0; i < ctx->commits.nr; i++) {
struct commit *c = ctx->commits.list[i];
Expand All @@ -1226,8 +1231,9 @@ static int write_graph_chunk_generation_data_overflow(struct hashfile *f,
}

static int write_graph_chunk_extra_edges(struct hashfile *f,
struct write_commit_graph_context *ctx)
void *data)
{
struct write_commit_graph_context *ctx = data;
struct commit **list = ctx->commits.list;
struct commit **last = ctx->commits.list + ctx->commits.nr;
struct commit_list *parent;
Expand Down Expand Up @@ -1280,8 +1286,9 @@ static int write_graph_chunk_extra_edges(struct hashfile *f,
}

static int write_graph_chunk_bloom_indexes(struct hashfile *f,
struct write_commit_graph_context *ctx)
void *data)
{
struct write_commit_graph_context *ctx = data;
struct commit **list = ctx->commits.list;
struct commit **last = ctx->commits.list + ctx->commits.nr;
uint32_t cur_pos = 0;
Expand Down Expand Up @@ -1315,8 +1322,9 @@ static void trace2_bloom_filter_settings(struct write_commit_graph_context *ctx)
}

static int write_graph_chunk_bloom_data(struct hashfile *f,
struct write_commit_graph_context *ctx)
void *data)
{
struct write_commit_graph_context *ctx = data;
struct commit **list = ctx->commits.list;
struct commit **last = ctx->commits.list + ctx->commits.nr;

Expand Down Expand Up @@ -1737,8 +1745,9 @@ static int write_graph_chunk_base_1(struct hashfile *f,
}

static int write_graph_chunk_base(struct hashfile *f,
struct write_commit_graph_context *ctx)
void *data)
{
struct write_commit_graph_context *ctx = data;
int num = write_graph_chunk_base_1(f, ctx->new_base_graph);

if (num != ctx->num_commit_graphs_after - 1) {
Expand All @@ -1750,7 +1759,7 @@ static int write_graph_chunk_base(struct hashfile *f,
}

typedef int (*chunk_write_fn)(struct hashfile *f,
struct write_commit_graph_context *ctx);
void *data);

struct chunk_info {
uint32_t id;
Expand Down

0 comments on commit eb90719

Please sign in to comment.