From: Patrick Steinhardt Date: Wed, 04 Nov 2026 15:57:32 GMT Subject: [PATCH 10/10] commit-graph: modernize function names Message-ID: <20261104-pks-commit-graph-write-refactorings-v1-10-d013d9401a59@pks.im> In-Reply-To: <20261104-pks-commit-graph-write-refactorings-v1-0-d013d9401a59@pks.im> Modernize a couple of function names of the commit-graph subsystem so that they follow our modern `_` naming schema. Signed-off-by: Patrick Steinhardt --- Documentation/gitformat-chunk.adoc | 2 +- builtin/commit-graph.c | 6 +++--- builtin/fetch.c | 2 +- builtin/gc.c | 2 +- commit-graph.c | 20 ++++++++++---------- commit-graph.h | 14 +++++++------- odb.c | 2 +- oss-fuzz/fuzz-commit-graph.c | 4 ++-- t/helper/test-read-graph.c | 2 +- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Documentation/gitformat-chunk.adoc b/Documentation/gitformat-chunk.adoc index 3315df6201d..061803932b4 100644 --- a/Documentation/gitformat-chunk.adoc +++ b/Documentation/gitformat-chunk.adoc @@ -118,7 +118,7 @@ Examples These file formats use the chunk-format API, and can be used as examples for future formats: -* *commit-graph:* see `write_commit_graph_file()` and `parse_commit_graph()` +* *commit-graph:* see `write_commit_graph_file()` and `commit_graph_parse()` in `commit-graph.c` for how the chunk-format API is used to write and parse the commit-graph file format documented in the commit-graph file format in linkgit:gitformat-commit-graph[5]. diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c index 218c30ed3ed..8194a528406 100644 --- a/builtin/commit-graph.c +++ b/builtin/commit-graph.c @@ -119,8 +119,8 @@ static int cmd_commit_graph_verify(int argc, if (!graph) return 1; - ret = verify_commit_graph(graph, flags); - free_commit_graph(graph); + ret = commit_graph_verify(graph, flags); + commit_graph_free(graph); if (incomplete_chain) { error("one or more commit-graph chain files could not be loaded"); @@ -324,7 +324,7 @@ static int cmd_commit_graph_write(int argc, stop_progress(&progress); } - if (write_commit_graph(repo, dir->abspath, &write_opts)) + if (commit_graph_write(repo, dir->abspath, &write_opts)) result = 1; cleanup: diff --git a/builtin/fetch.c b/builtin/fetch.c index 7278cee8ca7..cf8cafc4520 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -2949,7 +2949,7 @@ int cmd_fetch(int argc, if (graph_write_mode != GRAPH_WRITE_SKIP) { trace2_region_enter("fetch", "write-commit-graph", the_repository); - write_commit_graph(the_repository, + commit_graph_write(the_repository, the_repository->objects->source->path, &write_opts); trace2_region_leave("fetch", "write-commit-graph", diff --git a/builtin/gc.c b/builtin/gc.c index 7bf88861df0..68cb04a672d 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -741,7 +741,7 @@ int cmd_gc(int argc, if (!opts.quiet && !daemonized) write_opts.flags |= COMMIT_GRAPH_WRITE_PROGRESS; - write_commit_graph(the_repository, the_repository->objects->source->path, + commit_graph_write(the_repository, the_repository->objects->source->path, &write_opts); } diff --git a/commit-graph.c b/commit-graph.c index c82776b0667..da65cd3deb9 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -41,7 +41,7 @@ void git_test_write_commit_graph_or_die(struct repository *repo) if (git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0)) opts.flags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS; - if (write_commit_graph(repo, repo->objects->source->path, &opts)) + if (commit_graph_write(repo, repo->objects->source->path, &opts)) die("failed to write commit-graph under GIT_TEST_COMMIT_GRAPH"); } @@ -275,7 +275,7 @@ struct commit_graph *load_commit_graph_one_fd_st(struct repository *repo, graph_map = xmmap(NULL, graph_size, PROT_READ, MAP_PRIVATE, fd, 0); close(fd); - ret = parse_commit_graph(repo, graph_map, graph_size); + ret = commit_graph_parse(repo, graph_map, graph_size); if (ret) ret->dir = absolute_pathdup(dir); else @@ -375,7 +375,7 @@ static int graph_read_bloom_data(const unsigned char *chunk_start, return 0; } -struct commit_graph *parse_commit_graph(struct repository *r, +struct commit_graph *commit_graph_parse(struct repository *r, void *graph_map, size_t graph_size) { const unsigned char *data; @@ -686,7 +686,7 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct object_database *odb, graph_chain = g; valid = 1; } else { - free_commit_graph(g); + commit_graph_free(g); } break; @@ -830,14 +830,14 @@ struct bloom_filter_settings *get_bloom_filter_settings(struct repository *r) return NULL; } -void close_commit_graph(struct object_database *o) +void commit_graph_close(struct object_database *o) { if (!o->commit_graph) return; clear_commit_graph_data_slab(&commit_graph_data_slab); deinit_bloom_filters(); - free_commit_graph(o->commit_graph); + commit_graph_free(o->commit_graph); o->commit_graph = NULL; } @@ -2214,7 +2214,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx) ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 2] = new_base_hash; } - close_commit_graph(ctx->r->objects); + commit_graph_close(ctx->r->objects); finalize_hashfile(f, file_hash, FSYNC_COMPONENT_COMMIT_GRAPH, CSUM_HASH_IN_STREAM | CSUM_FSYNC); free_chunkfile(cf); @@ -2542,7 +2542,7 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx) strbuf_release(&path); } -int write_commit_graph(struct repository *r, +int commit_graph_write(struct repository *r, const char *dir, const struct commit_graph_write_options *opts) { @@ -2904,7 +2904,7 @@ static int verify_one_commit_graph(struct commit_graph *g, return verify_commit_graph_error; } -int verify_commit_graph(struct commit_graph *g, +int commit_graph_verify(struct commit_graph *g, enum commit_graph_verify_flags flags) { struct progress *progress = NULL; @@ -2937,7 +2937,7 @@ int verify_commit_graph(struct commit_graph *g, return local_error; } -void free_commit_graph(struct commit_graph *g) +void commit_graph_free(struct commit_graph *g) { while (g) { struct commit_graph *next = g->base_graph; diff --git a/commit-graph.h b/commit-graph.h index 80d59bd23bd..2156499a688 100644 --- a/commit-graph.h +++ b/commit-graph.h @@ -135,9 +135,9 @@ struct repo_settings; /* * Callers should initialize the repo_settings with prepare_repo_settings() - * prior to calling parse_commit_graph(). + * prior to calling commit_graph_parse(). */ -struct commit_graph *parse_commit_graph(struct repository *r, +struct commit_graph *commit_graph_parse(struct repository *r, void *graph_map, size_t graph_size); /* @@ -186,7 +186,7 @@ struct commit_graph_write_options { } /* - * The write_commit_graph* methods return zero on success + * The commit_graph_write* methods return zero on success * and a negative value on failure. Note that if the repository * is not compatible with the commit-graph feature, then the * methods will return 0 without writing a commit-graph. @@ -195,7 +195,7 @@ struct commit_graph_write_options { * canonicalized internally so that it compares equal to the directory of * graphs that have already been loaded. */ -int write_commit_graph(struct repository *r, +int commit_graph_write(struct repository *r, const char *dir, const struct commit_graph_write_options *opts); @@ -204,11 +204,11 @@ enum commit_graph_verify_flags { COMMIT_GRAPH_VERIFY_PROGRESS = (1 << 1), }; -int verify_commit_graph(struct commit_graph *g, +int commit_graph_verify(struct commit_graph *g, enum commit_graph_verify_flags flags); -void close_commit_graph(struct object_database *); -void free_commit_graph(struct commit_graph *); +void commit_graph_close(struct object_database *); +void commit_graph_free(struct commit_graph *); /* * Disable further use of the commit graph in this process when parsing a diff --git a/odb.c b/odb.c index 2c93a9490c6..b89457d0c91 100644 --- a/odb.c +++ b/odb.c @@ -739,7 +739,7 @@ struct object_database *odb_new(struct repository *repo, void odb_close(struct object_database *o) { odb_source_close(o->source); - close_commit_graph(o); + commit_graph_close(o); } static void odb_free_sources(struct object_database *o) diff --git a/oss-fuzz/fuzz-commit-graph.c b/oss-fuzz/fuzz-commit-graph.c index 59bbb849d1e..e941cd9fc56 100644 --- a/oss-fuzz/fuzz-commit-graph.c +++ b/oss-fuzz/fuzz-commit-graph.c @@ -23,9 +23,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) the_repository->settings.initialized = 1; the_repository->settings.commit_graph_generation_version = 2; the_repository->settings.commit_graph_changed_paths_version = 1; - g = parse_commit_graph(the_repository, (void *)data, size); + g = commit_graph_parse(the_repository, (void *)data, size); repo_clear(the_repository); - free_commit_graph(g); + commit_graph_free(g); return 0; } diff --git a/t/helper/test-read-graph.c b/t/helper/test-read-graph.c index aceac4f6995..9642e55b8c0 100644 --- a/t/helper/test-read-graph.c +++ b/t/helper/test-read-graph.c @@ -119,6 +119,6 @@ int cmd__read_graph(int argc, const char **argv) } done: - free_commit_graph(graph); + commit_graph_free(graph); return ret; } -- 2.56.0.500.g5d06dc02cd.dirty