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

Re: [PATCH v2 2/2] commit: detect commits that exist in commit-graph but not in the ODB

From
Taylor Blau <me@ttaylorr.com>
Date
Oct 30, 2023, 21:31 UTC
Message-ID
<ZUAgyW+4dCcKRck8@nand.local>
In-Reply-To
<0476d4855562b677ced106a4cc7788b46434cf21.1698060036.git.ps@pks.im>
On Mon, Oct 23, 2023 at 01:27:20PM +0200, Patrick Steinhardt wrote:
Show 10 quoted lines
> @@ -572,8 +573,21 @@ int repo_parse_commit_internal(struct repository *r,
>  		return -1;
>  	if (item->object.parsed)
>  		return 0;
> -	if (use_commit_graph && parse_commit_in_graph(r, item))
> +	if (use_commit_graph && parse_commit_in_graph(r, item)) {
> +		static int object_paranoia = -1;
> +
> +		if (object_paranoia == -1)
> +			object_paranoia = git_env_bool(GIT_COMMIT_GRAPH_PARANOIA, 1);

The same note here about object_paranoia versus graph_paranoia, but otherwise this patch looks good to me, modulo one typo below.

Show 16 quoted lines
> @@ -842,4 +842,31 @@ test_expect_success 'stale commit cannot be parsed when given directly' '
>  	)
>  '
>
> +test_expect_success 'stale commit cannot be parsed when traversing graph' '
> +	test_when_finished "rm -rf repo" &&
> +	git init repo &&
> +	(
> +		cd repo &&
> +
> +		test_commit A &&
> +		test_commit B &&
> +		test_commit C &&
> +		git commit-graph write --reachable &&
> +
> +		# Corrupt the repository by deleting the intermittent commit
s/intermittent/intermediate
Show 13 quoted lines
> +		# object. Commands should notice that this object is absent and
> +		# thus that the repository is corrupt even if the commit graph
> +		# exists.
> +		oid=$(git rev-parse B) &&
> +		rm .git/objects/"$(test_oid_to_path "$oid")" &&
> +
> +		# Again, we should be able to parse the commit when not
> +		# being paranoid about commit graph staleness...
> +		GIT_COMMIT_GRAPH_PARANOIA=false git rev-parse HEAD~2 &&
> +		# ... but fail when we are paranoid.
> +		test_must_fail git rev-parse HEAD~2 2>error &&
> +		grep "error: commit $oid exists in commit-graph but not in the object database" error
> +	)

Thanks, Taylor

Previous: Junio C HamanoNext: Patrick Steinhardt
Message 9 of 18 in “commit-graph: detect commits missing in ODB”
  1. 0/2 commit-graph: detect commits missing in ODBPatrick Steinhardt, Oct 23, 2023
  2. 1/2 commit-graph: introduce envvar to disable commit existence checksPatrick Steinhardt, Oct 23, 2023
  3. Taylor BlauOct 30, 2023
  4. Patrick SteinhardtOct 31, 2023
  5. 2/2 commit: detect commits that exist in commit-graph but not in the ODBPatrick Steinhardt, Oct 23, 2023
  6. Junio C HamanoOct 24, 2023
  7. Taylor BlauOct 30, 2023
  8. Junio C HamanoOct 31, 2023
  9. Taylor BlauOct 30, 2023
  10. 0/2 commit-graph: detect commits missing in ODBPatrick Steinhardt, Oct 31, 2023
  11. 1/2 commit-graph: introduce envvar to disable commit existence checksPatrick Steinhardt, Oct 31, 2023
  12. 2/2 commit: detect commits that exist in commit-graph but not in the ODBPatrick Steinhardt, Oct 31, 2023
  13. Taylor BlauOct 31, 2023
  14. Junio C HamanoOct 31, 2023
  15. Junio C HamanoNov 1, 2023
  16. Patrick SteinhardtNov 1, 2023
  17. Junio C HamanoNov 1, 2023
  18. Junio C HamanoOct 31, 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.