* Return 1 if commit_graph is non-NULL, and 0 otherwise. * * On the first invocation, this function attempts to load the commit * graph if the repository is configured to have one. */
| 736 | * graph if the repository is configured to have one. |
| 737 | */ |
| 738 | static struct commit_graph *prepare_commit_graph(struct repository *r) |
| 739 | { |
| 740 | struct odb_source *source; |
| 741 | |
| 742 | /* |
| 743 | * Early return if there is no object database or if the commit graph is |
| 744 | * disabled. |
| 745 | * |
| 746 | * This must come before the "already attempted?" check below, because |
| 747 | * we want to disable even an already-loaded graph file. |
| 748 | */ |
| 749 | if (!r->objects || r->commit_graph_disabled) |
| 750 | return NULL; |
| 751 | |
| 752 | if (r->objects->commit_graph_attempted) |
| 753 | return r->objects->commit_graph; |
| 754 | r->objects->commit_graph_attempted = 1; |
| 755 | |
| 756 | prepare_repo_settings(r); |
| 757 | |
| 758 | if (!git_env_bool(GIT_TEST_COMMIT_GRAPH, 0) && |
| 759 | r->settings.core_commit_graph != 1) |
| 760 | /* |
| 761 | * This repository is not configured to use commit graphs, so |
| 762 | * do not load one. (But report commit_graph_attempted anyway |
| 763 | * so that commit graph loading is not attempted again for this |
| 764 | * repository.) |
| 765 | */ |
| 766 | return NULL; |
| 767 | |
| 768 | if (!commit_graph_compatible(r)) |
| 769 | return NULL; |
| 770 | |
| 771 | odb_prepare_alternates(r->objects); |
| 772 | for (source = r->objects->sources; source; source = source->next) { |
| 773 | r->objects->commit_graph = read_commit_graph_one(source); |
| 774 | if (r->objects->commit_graph) |
| 775 | break; |
| 776 | } |
| 777 | |
| 778 | return r->objects->commit_graph; |
| 779 | } |
| 780 | |
| 781 | int generation_numbers_enabled(struct repository *r) |
| 782 | { |
no test coverage detected