All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: Taylor Blau <me@ttaylorr.com>, Derrick Stolee <dstolee@microsoft.com>
Subject: Re: [PATCH 6/6] commit-graph: report incomplete chains during verification
Date: Thu, 28 Sep 2023 00:30:58 -0400	[thread overview]
Message-ID: <20230928043058.GA57926@coredump.intra.peff.net> (raw)
In-Reply-To: <20230926060430.GF1341418@coredump.intra.peff.net>

On Tue, Sep 26, 2023 at 02:04:30AM -0400, Jeff King wrote:

> @@ -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

  reply	other threads:[~2023-09-28  4:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-26  5:54 [PATCH 0/6] some "commit-graph verify" fixes for chains Jeff King
2023-09-26  5:56 ` [PATCH 1/6] commit-graph: factor out chain opening function Jeff King
2023-09-26  5:57 ` [PATCH 2/6] commit-graph: check mixed generation validation when loading chain file Jeff King
2023-09-26  5:58 ` [PATCH 3/6] t5324: harmonize sha1/sha256 graph chain corruption Jeff King
2023-09-26  6:00 ` [PATCH 4/6] commit-graph: detect read errors when verifying graph chain Jeff King
2023-09-26  6:03 ` [PATCH 5/6] commit-graph: tighten chain size check Jeff King
2023-09-26  6:04 ` [PATCH 6/6] commit-graph: report incomplete chains during verification Jeff King
2023-09-28  4:30   ` Jeff King [this message]
2023-09-28  4:37 ` [PATCH v2 0/6] some "commit-graph verify" fixes for chains Jeff King
2023-09-28  4:38   ` [PATCH v2 1/6] commit-graph: factor out chain opening function Jeff King
2023-09-28  4:38   ` [PATCH v2 2/6] commit-graph: check mixed generation validation when loading chain file Jeff King
2023-09-28  4:38   ` [PATCH v2 3/6] t5324: harmonize sha1/sha256 graph chain corruption Jeff King
2023-09-28  4:38   ` [PATCH v2 4/6] commit-graph: detect read errors when verifying graph chain Jeff King
2023-09-28  4:39   ` [PATCH v2 5/6] commit-graph: tighten chain size check Jeff King
2023-09-28  4:39   ` [PATCH v2 6/6] commit-graph: report incomplete chains during verification Jeff King
2023-10-05 17:38   ` [PATCH v2 0/6] some "commit-graph verify" fixes for chains Taylor Blau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230928043058.GA57926@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=dstolee@microsoft.com \
    --cc=git@vger.kernel.org \
    --cc=me@ttaylorr.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.