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

Re: [PATCH 2/3] commit-graph: introduce `repo_find_commit_pos_in_graph()`

From
Derrick Stolee <derrickstolee@github.com>
Date
Jul 15, 2022, 03:17 UTC
Message-ID
<3036d949-63b2-9d6c-b3f6-0075fe9e1ca5@github.com>
In-Reply-To
<e988c974119edbabc06dae6d24810fc0bafbdc94.1657667404.git.me@ttaylorr.com>
On 7/12/2022 7:10 PM, Taylor Blau wrote:
Show 8 quoted lines
> +int repo_find_commit_pos_in_graph(struct repository *r, struct commit *c,
> +				  uint32_t *pos)
> +{
> +	if (!prepare_commit_graph(r))
> +		return 0;
> +	return find_commit_pos_in_graph(c, r->objects->commit_graph, pos);
> +}
> +
This is absolutely correct for the given prototype.
Show 8 quoted lines
>  void load_commit_graph_info(struct repository *r, struct commit *item)
>  {
>  	uint32_t pos;
> -	if (!prepare_commit_graph(r))
> -		return;
> -	if (find_commit_pos_in_graph(item, r->objects->commit_graph, &pos))
> +	if (repo_find_commit_pos_in_graph(r, item, &pos))
>  		fill_commit_graph_info(item, r->objects->commit_graph, pos);

Normally I would complain about referring directly to r->objects->commit_graph without an explicit prepare_commit_graph() in the method. My initial thought was that we would need to know that the new method prepares the graph, but obviously the commit-graph needs to exist and be prepared if we are loading a position from it.

All good here.

Thanks, -Stolee

Previous: Taylor BlauNext: Taylor Blau
Message 8 of 12 in “commit-graph: fix corruption during generation v2 upgrade”
  1. 0/3 commit-graph: fix corruption during generation v2 upgradeTaylor Blau, Jul 12, 2022
  2. 1/3 t5318: demonstrate commit-graph generation v2 corruptionTaylor Blau, Jul 12, 2022
  3. Derrick StoleeJul 15, 2022
  4. Taylor BlauJul 15, 2022
  5. Junio C HamanoJul 16, 2022
  6. Taylor BlauJul 16, 2022
  7. 2/3 commit-graph: introduce `repo_find_commit_pos_in_graph()`Taylor Blau, Jul 12, 2022
  8. Derrick StoleeJul 15, 2022
  9. 3/3 commit-graph: fix corrupt upgrade from generation v1 to v2Taylor Blau, Jul 12, 2022
  10. Junio C HamanoJul 13, 2022
  11. Taylor BlauJul 15, 2022
  12. Derrick StoleeJul 15, 2022

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.