MCPcopy Index your code
hub / github.com/git/git / write_commit_graph

Function write_commit_graph

commit-graph.c:2554–2741  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2552}
2553
2554int write_commit_graph(struct odb_source *source,
2555 const struct string_list *const pack_indexes,
2556 struct oidset *commits,
2557 enum commit_graph_write_flags flags,
2558 const struct commit_graph_opts *opts)
2559{
2560 struct repository *r = source->odb->repo;
2561 struct write_commit_graph_context ctx = {
2562 .r = r,
2563 .odb_source = source,
2564 .append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0,
2565 .report_progress = flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0,
2566 .split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0,
2567 .opts = opts,
2568 .total_bloom_filter_data_size = 0,
2569 .write_generation_data = (get_configured_generation_version(r) == 2),
2570 .num_generation_data_overflows = 0,
2571 };
2572 uint32_t i;
2573 int res = 0;
2574 int replace = 0;
2575 struct bloom_filter_settings bloom_settings = DEFAULT_BLOOM_FILTER_SETTINGS;
2576 struct topo_level_slab topo_levels;
2577 struct commit_graph *g;
2578
2579 prepare_repo_settings(r);
2580 if (!r->settings.core_commit_graph) {
2581 warning(_("attempting to write a commit-graph, but 'core.commitGraph' is disabled"));
2582 return 0;
2583 }
2584 if (!commit_graph_compatible(r))
2585 return 0;
2586 if (r->settings.commit_graph_changed_paths_version < -1
2587 || r->settings.commit_graph_changed_paths_version > 2) {
2588 warning(_("attempting to write a commit-graph, but "
2589 "'commitGraph.changedPathsVersion' (%d) is not supported"),
2590 r->settings.commit_graph_changed_paths_version);
2591 return 0;
2592 }
2593
2594 bloom_settings.hash_version = r->settings.commit_graph_changed_paths_version;
2595 bloom_settings.bits_per_entry = git_env_ulong("GIT_TEST_BLOOM_SETTINGS_BITS_PER_ENTRY",
2596 bloom_settings.bits_per_entry);
2597 bloom_settings.num_hashes = git_env_ulong("GIT_TEST_BLOOM_SETTINGS_NUM_HASHES",
2598 bloom_settings.num_hashes);
2599 bloom_settings.max_changed_paths = git_env_ulong("GIT_TEST_BLOOM_SETTINGS_MAX_CHANGED_PATHS",
2600 bloom_settings.max_changed_paths);
2601 ctx.bloom_settings = &bloom_settings;
2602
2603 init_topo_level_slab(&topo_levels);
2604 ctx.topo_levels = &topo_levels;
2605
2606 g = prepare_commit_graph(ctx.r);
2607 for (struct commit_graph *chain = g; chain; chain = chain->base_graph)
2608 g->topo_levels = &topo_levels;
2609
2610 if (flags & COMMIT_GRAPH_WRITE_BLOOM_FILTERS)
2611 ctx.changed_paths = 1;

Callers 2

graph_writeFunction · 0.85

Calls 15

prepare_repo_settingsFunction · 0.85
warningFunction · 0.85
commit_graph_compatibleFunction · 0.85
git_env_ulongFunction · 0.85
prepare_commit_graphFunction · 0.85
xstrdupFunction · 0.85
odb_count_objectsFunction · 0.85
oidreadFunction · 0.85
st_multFunction · 0.85
oid_array_appendFunction · 0.85
fill_oids_from_packsFunction · 0.85

Tested by

no test coverage detected