diff options
| author | Junio C Hamano <gitster@pobox.com> | 2023-10-04 13:28:53 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2023-10-04 13:28:53 -0700 |
| commit | c3c00206739afc1016277d5a670d377bef85e69b (patch) | |
| tree | fc365d3811cd9b60adee59ac1c46d02ccf1be38b /builtin/commit-graph.c | |
| parent | Merge branch 'ks/ref-filter-mailmap' (diff) | |
| parent | commit-graph: report incomplete chains during verification (diff) | |
| download | git-c3c00206739afc1016277d5a670d377bef85e69b.tar.gz git-c3c00206739afc1016277d5a670d377bef85e69b.zip | |
Merge branch 'jk/commit-graph-verify-fix'
Various fixes to "git commit-graph verify".
* jk/commit-graph-verify-fix:
commit-graph: report incomplete chains during verification
commit-graph: tighten chain size check
commit-graph: detect read errors when verifying graph chain
t5324: harmonize sha1/sha256 graph chain corruption
commit-graph: check mixed generation validation when loading chain file
commit-graph: factor out chain opening function
Diffstat (limited to 'builtin/commit-graph.c')
| -rw-r--r-- | builtin/commit-graph.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c index c88389df24..f5e66e9969 100644 --- a/builtin/commit-graph.c +++ b/builtin/commit-graph.c @@ -69,10 +69,12 @@ static int graph_verify(int argc, const char **argv, const char *prefix) struct commit_graph *graph = NULL; struct object_directory *odb = NULL; char *graph_name; - int open_ok; + char *chain_name; + enum { OPENED_NONE, OPENED_GRAPH, OPENED_CHAIN } opened = OPENED_NONE; int fd; struct stat st; int flags = 0; + int incomplete_chain = 0; int ret; static struct option builtin_commit_graph_verify_options[] = { @@ -102,24 +104,39 @@ static int graph_verify(int argc, const char **argv, const char *prefix) odb = find_odb(the_repository, opts.obj_dir); graph_name = get_commit_graph_filename(odb); - open_ok = open_commit_graph(graph_name, &fd, &st); - if (!open_ok && errno != ENOENT) + chain_name = get_commit_graph_chain_filename(odb); + if (open_commit_graph(graph_name, &fd, &st)) + opened = OPENED_GRAPH; + else if (errno != ENOENT) die_errno(_("Could not open commit-graph '%s'"), graph_name); + else if (open_commit_graph_chain(chain_name, &fd, &st)) + opened = OPENED_CHAIN; + else if (errno != ENOENT) + die_errno(_("could not open commit-graph chain '%s'"), chain_name); FREE_AND_NULL(graph_name); + FREE_AND_NULL(chain_name); FREE_AND_NULL(options); - if (open_ok) + if (opened == OPENED_NONE) + return 0; + else if (opened == OPENED_GRAPH) graph = load_commit_graph_one_fd_st(the_repository, fd, &st, odb); else - graph = read_commit_graph_one(the_repository, odb); + graph = load_commit_graph_chain_fd_st(the_repository, fd, &st, + &incomplete_chain); - /* Return failure if open_ok predicted success */ if (!graph) - return !!open_ok; + return 1; ret = verify_commit_graph(the_repository, graph, flags); free_commit_graph(graph); + + if (incomplete_chain) { + error("one or more commit-graph chain files could not be loaded"); + ret |= 1; + } + return ret; } |
