| 64 | } |
| 65 | |
| 66 | static int graph_verify(int argc, const char **argv, const char *prefix, |
| 67 | struct repository *repo UNUSED) |
| 68 | { |
| 69 | struct commit_graph *graph = NULL; |
| 70 | struct odb_source *source = NULL; |
| 71 | char *graph_name; |
| 72 | char *chain_name; |
| 73 | enum { OPENED_NONE, OPENED_GRAPH, OPENED_CHAIN } opened = OPENED_NONE; |
| 74 | int fd; |
| 75 | struct stat st; |
| 76 | int flags = 0; |
| 77 | int incomplete_chain = 0; |
| 78 | int ret; |
| 79 | |
| 80 | static struct option builtin_commit_graph_verify_options[] = { |
| 81 | OPT_BOOL(0, "shallow", &opts.shallow, |
| 82 | N_("if the commit-graph is split, only verify the tip file")), |
| 83 | OPT_BOOL(0, "progress", &opts.progress, |
| 84 | N_("force progress reporting")), |
| 85 | OPT_END(), |
| 86 | }; |
| 87 | struct option *options = add_common_options(builtin_commit_graph_verify_options); |
| 88 | |
| 89 | trace2_cmd_mode("verify"); |
| 90 | |
| 91 | opts.progress = isatty(2); |
| 92 | argc = parse_options(argc, argv, prefix, |
| 93 | options, |
| 94 | builtin_commit_graph_verify_usage, 0); |
| 95 | if (argc) |
| 96 | usage_with_options(builtin_commit_graph_verify_usage, options); |
| 97 | |
| 98 | if (!opts.obj_dir) |
| 99 | opts.obj_dir = repo_get_object_directory(the_repository); |
| 100 | if (opts.shallow) |
| 101 | flags |= COMMIT_GRAPH_VERIFY_SHALLOW; |
| 102 | if (opts.progress) |
| 103 | flags |= COMMIT_GRAPH_WRITE_PROGRESS; |
| 104 | |
| 105 | source = odb_find_source_or_die(the_repository->objects, opts.obj_dir); |
| 106 | graph_name = get_commit_graph_filename(source); |
| 107 | chain_name = get_commit_graph_chain_filename(source); |
| 108 | if (open_commit_graph(graph_name, &fd, &st)) |
| 109 | opened = OPENED_GRAPH; |
| 110 | else if (errno != ENOENT) |
| 111 | die_errno(_("Could not open commit-graph '%s'"), graph_name); |
| 112 | else if (open_commit_graph_chain(chain_name, &fd, &st, |
| 113 | the_repository->hash_algo)) |
| 114 | opened = OPENED_CHAIN; |
| 115 | else if (errno != ENOENT) |
| 116 | die_errno(_("could not open commit-graph chain '%s'"), chain_name); |
| 117 | |
| 118 | FREE_AND_NULL(graph_name); |
| 119 | FREE_AND_NULL(chain_name); |
| 120 | FREE_AND_NULL(options); |
| 121 | |
| 122 | if (opened == OPENED_NONE) |
| 123 | return 0; |
nothing calls this directly
no test coverage detected