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

Re: [PATCH 3/4] fsck: check rev-index position values

From
Taylor Blau <me@ttaylorr.com>
Date
Apr 17, 2023, 22:52 UTC
Message-ID
<ZD3NscowbkXizxCv@nand.local>
In-Reply-To
<adbe9c8ee90e087e864bd9e0c67338974b5dbc8d.1681748502.git.gitgitgadget@gmail.com>
On Mon, Apr 17, 2023 at 04:21:40PM +0000, Derrick Stolee via GitGitGadget wrote:
Show 12 quoted lines
> +	for (size_t i = 0; i < p->num_objects; i++) {
> +		uint32_t nr = p->revindex[i].nr;
> +		uint32_t rev_val = get_be32(p->revindex_data + i);
> +
> +		if (nr != rev_val) {
> +			error(_("invalid rev-index position at %"PRIu64": %"PRIu32" != %"PRIu32""),
> +			      (uint64_t)i, nr, rev_val);
> +			res = -1;
> +		}
> +	}
> +
> +	return res;
Very clever.

I thought about it for a while, and I am pretty confident that this is the cleanest you can get this loop to be. You could do something like building the forward index out of inverting the values in the .rev file, but everything I came up with based on that ended up being circular and not demonstrating anything interesting at all.

Thanks, Taylor

Previous: Derrick StoleeNext: Derrick Stolee via GitGitGadget
Message 15 of 19 in “git fsck: check pack rev-index files”
  1. 0/4 git fsck: check pack rev-index filesDerrick Stolee via GitGitGadget, Apr 17, 2023
  2. 1/4 fsck: create scaffolding for rev-index checksDerrick Stolee via GitGitGadget, Apr 17, 2023
  3. Taylor BlauApr 17, 2023
  4. 2/4 fsck: check rev-index checksumsDerrick Stolee via GitGitGadget, Apr 17, 2023
  5. Junio C HamanoApr 17, 2023
  6. Derrick StoleeApr 18, 2023
  7. Taylor BlauApr 17, 2023
  8. Derrick StoleeApr 18, 2023
  9. Taylor BlauApr 18, 2023
  10. Derrick StoleeApr 18, 2023
  11. Taylor BlauApr 18, 2023
  12. 3/4 fsck: check rev-index position valuesDerrick Stolee via GitGitGadget, Apr 17, 2023
  13. Junio C HamanoApr 17, 2023
  14. Derrick StoleeApr 18, 2023
  15. Taylor BlauApr 17, 2023
  16. 4/4 fsck: validate .rev file headerDerrick Stolee via GitGitGadget, Apr 17, 2023
  17. Junio C HamanoApr 17, 2023
  18. Taylor BlauApr 18, 2023
  19. Junio C HamanoApr 18, 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.