git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 6/6] commit-graph: report incomplete chains during verification

From
Jeff King <peff@peff.net>
Date
Sep 28, 2023, 04:30 UTC
Message-ID
<20230928043058.GA57926@coredump.intra.peff.net>
In-Reply-To
<20230926060430.GF1341418@coredump.intra.peff.net>
On Tue, Sep 26, 2023 at 02:04:30AM -0400, Jeff King wrote:
Show 8 quoted lines
> @@ -608,6 +611,7 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,
>  
>  		if (!valid) {
>  			warning(_("unable to find all commit-graph files"));
> +			*incomplete_chain = 1;
>  			break;
>  		}
>  	}
Reviewing my own patch since I noticed it misses a case. ;)
The whole function here looks like (abbreviated):
  int valid = 1;
  for (i = 0; i < count; i++) {
          if (get_oid_hex(line.buf, &oids[i])) {
                  warning(_("invalid commit-graph chain: line '%s' not a hash"),
                          line.buf);
                  valid = 0;
                  break;
          }
  
          valid = 0;
          for (odb = r->objects->odb; odb; odb = odb->next) {
                  struct commit_graph *g = load_commit_graph_one(r, graph_name, odb);
                  if (g) {
                          if (add_graph_to_chain(g, graph_chain, oids, i)) {
                                  graph_chain = g;
                                  valid = 1;
                          }
  
                          break;
                  }
          }
  
          if (!valid) {
                  warning(_("unable to find all commit-graph files"));
                  break;
          }
  }

My patch updates the final "if (!valid)" check, which covers anything that happened in the loop over the odb (i.e., finding and opening the file itself). But if we see a line which does not parse as an oid, we break out of the outer loop earlier. We set "valid", but nobody looks at it! So the caller would not be correctly notified that we had an error in that case.

The fix is simple: we can just check "valid" after leaving the outer loop, which covers both cases. And we'll want an extra test to check it. This is actually covered by the test modified earlier in patch 3, where sha1 and sha256 produced different results. I fixed it there by consistently corrupting the first line of the file, but we really want to check both cases.

I'll send a re-roll in a moment.
-Peff
Previous: Jeff KingNext: Jeff King
Message 8 of 16 in “some "commit-graph verify" fixes for chains”
  1. 0/6 some "commit-graph verify" fixes for chainsJeff King, Sep 26, 2023
  2. 1/6 commit-graph: factor out chain opening functionJeff King, Sep 26, 2023
  3. 2/6 commit-graph: check mixed generation validation when loading chain fileJeff King, Sep 26, 2023
  4. 3/6 t5324: harmonize sha1/sha256 graph chain corruptionJeff King, Sep 26, 2023
  5. 4/6 commit-graph: detect read errors when verifying graph chainJeff King, Sep 26, 2023
  6. 5/6 commit-graph: tighten chain size checkJeff King, Sep 26, 2023
  7. 6/6 commit-graph: report incomplete chains during verificationJeff King, Sep 26, 2023
  8. Jeff KingSep 28, 2023
  9. 0/6 some "commit-graph verify" fixes for chainsJeff King, Sep 28, 2023
  10. 1/6 commit-graph: factor out chain opening functionJeff King, Sep 28, 2023
  11. 2/6 commit-graph: check mixed generation validation when loading chain fileJeff King, Sep 28, 2023
  12. 3/6 t5324: harmonize sha1/sha256 graph chain corruptionJeff King, Sep 28, 2023
  13. 4/6 commit-graph: detect read errors when verifying graph chainJeff King, Sep 28, 2023
  14. 5/6 commit-graph: tighten chain size checkJeff King, Sep 28, 2023
  15. 6/6 commit-graph: report incomplete chains during verificationJeff King, Sep 28, 2023
  16. Taylor BlauOct 5, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.