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

Re: [PATCH 6/8] commit-graph.c: simplify 'fill_oids_from_commits'

From
Jeff King <peff@peff.net>
Date
May 7, 2020, 20:21 UTC
Message-ID
<20200507202148.GD29683@coredump.intra.peff.net>
In-Reply-To
<7e9d8c1f1a124171ebb5b4d874718053d1c9064a.1588641176.git.me@ttaylorr.com>
On Mon, May 04, 2020 at 07:13:54PM -0600, Taylor Blau wrote:
Show 12 quoted lines
> In the previous handful of commits, both 'git commit-graph write
> --reachable' and '--stdin-commits' learned to peel tags down to the
> commits which they refer to before passing them into the commit-graph
> internals.
> 
> This makes the call to 'lookup_commit_reference_gently()' inside of
> 'fill_oids_from_commits()' a noop, since all OIDs are commits by that
> point.
> 
> As such, remove the call entirely, as well as the progress meter, which
> has been split and moved out to the callers in the aforementioned
> earlier commits.

Yep, all this makes sense. I agree with Stolee that it's unfortunate we can't just reuse the oidset now, but we do need the flattened array view here. We could perhaps create such an array from the beginning (perhaps using an oid_array), but we do need to care about de-duping the input. That can be done easily with the sorted list, but there are pathological corner cases where the performance is worse (e.g., if you have a ton of refs all pointing to the same tags, like if you happened to be storing the refs for 20,000 forks of the kernel all in one giant repo).

I think we'd eventually turn all these into "struct commit" (and indeed, we already do in --stdin-commits when we try to peel). So another alternative would be passing in an object_array(). But I guess that would require surgery to the rest of the commit-graph code to work with that instead of the oid list.

Show 19 quoted lines
>  	while ((oid = oidset_iter_next(&iter))) {
> -		struct commit *result;
> -
> -		display_progress(ctx->progress, ++i);
> -
> -		result = lookup_commit_reference_gently(ctx->r, oid, 1);
> -		if (result) {
> -			ALLOC_GROW(ctx->oids.list, ctx->oids.nr + 1, ctx->oids.alloc);
> -			oidcpy(&ctx->oids.list[ctx->oids.nr], &(result->object.oid));
> -			ctx->oids.nr++;
> -		} else if (ctx->check_oids) {
> -			error(_("invalid commit object id: %s"),
> -			      oid_to_hex(oid));
> -			return -1;
> -		}
> +		ALLOC_GROW(ctx->oids.list, ctx->oids.nr + 1, ctx->oids.alloc);
> +		oidcpy(&ctx->oids.list[ctx->oids.nr], oid);
> +		ctx->oids.nr++;
>  	}

I wondered if it's worth asserting that everything we got here is a commit. But it's not cheap to make that check, and anyway we'd presumably just barf later on when we try to resolve the oids to commits. So there's little point in spending cycles to catch it here.

-Peff
Previous: Derrick StoleeNext: Taylor Blau
Message 19 of 59 in “commit-graph: drop CHECK_OIDS, peel in callers”
  1. 0/8 commit-graph: drop CHECK_OIDS, peel in callersTaylor Blau, May 5, 2020
  2. 1/8 commit-graph.c: extract 'refs_cb_data'Taylor Blau, May 5, 2020
  3. 2/8 commit-graph.c: show progress of finding reachable commitsTaylor Blau, May 5, 2020
  4. Derrick StoleeMay 5, 2020
  5. Taylor BlauMay 5, 2020
  6. 3/8 commit-graph.c: peel refs in 'add_ref_to_set'Taylor Blau, May 5, 2020
  7. Jeff KingMay 7, 2020
  8. Taylor BlauMay 13, 2020
  9. Jeff KingMay 13, 2020
  10. 4/8 builtin/commit-graph.c: extract 'read_one_commit()'Taylor Blau, May 5, 2020
  11. Jeff KingMay 7, 2020
  12. Taylor BlauMay 13, 2020
  13. 5/8 builtin/commit-graph.c: dereference tags in builtinTaylor Blau, May 5, 2020
  14. Derrick StoleeMay 5, 2020
  15. Taylor BlauMay 5, 2020
  16. Jeff KingMay 7, 2020
  17. 6/8 commit-graph.c: simplify 'fill_oids_from_commits'Taylor Blau, May 5, 2020
  18. Derrick StoleeMay 5, 2020
  19. Jeff KingMay 7, 2020
  20. 7/8 t5318: reorder test below 'graph_read_expect'Taylor Blau, May 5, 2020
  21. 8/8 commit-graph: drop COMMIT_GRAPH_WRITE_CHECK_OIDS flagTaylor Blau, May 5, 2020
  22. Derrick StoleeMay 5, 2020
  23. Taylor BlauMay 5, 2020
  24. Jeff KingMay 7, 2020
  25. Taylor BlauMay 13, 2020
  26. Derrick StoleeMay 5, 2020
  27. Taylor BlauMay 5, 2020
  28. 0/8 commit-graph: drop CHECK_OIDS, peel in callersTaylor Blau, May 6, 2020
  29. 1/8 commit-graph.c: extract 'refs_cb_data'Taylor Blau, May 6, 2020
  30. 2/8 commit-graph.c: show progress of finding reachable commitsTaylor Blau, May 6, 2020
  31. 3/8 commit-graph.c: peel refs in 'add_ref_to_set'Taylor Blau, May 6, 2020
  32. 4/8 builtin/commit-graph.c: extract 'read_one_commit()'Taylor Blau, May 6, 2020
  33. 5/8 builtin/commit-graph.c: dereference tags in builtinTaylor Blau, May 6, 2020
  34. 6/8 commit-graph.c: simplify 'fill_oids_from_commits'Taylor Blau, May 6, 2020
  35. 7/8 t5318: reorder test below 'graph_read_expect'Taylor Blau, May 6, 2020
  36. 8/8 commit-graph: drop COMMIT_GRAPH_WRITE_CHECK_OIDS flagTaylor Blau, May 6, 2020
  37. Jeff KingMay 7, 2020
  38. 0/8 commit-graph: drop CHECK_OIDS, peel in callersTaylor Blau, May 13, 2020
  39. 1/8 commit-graph.c: extract 'refs_cb_data'Taylor Blau, May 13, 2020
  40. 2/8 commit-graph.c: show progress of finding reachable commitsTaylor Blau, May 13, 2020
  41. 3/8 commit-graph.c: peel refs in 'add_ref_to_set'Taylor Blau, May 13, 2020
  42. 4/8 builtin/commit-graph.c: extract 'read_one_commit()'Taylor Blau, May 13, 2020
  43. Jeff KingMay 14, 2020
  44. Taylor BlauMay 14, 2020
  45. Junio C HamanoMay 14, 2020
  46. Taylor BlauMay 18, 2020
  47. 5/8 builtin/commit-graph.c: dereference tags in builtinTaylor Blau, May 13, 2020
  48. Jeff KingMay 14, 2020
  49. Taylor BlauMay 14, 2020
  50. commit-graph: fix "Collecting commits from input" progress lineSZEDER Gábor, Jul 10, 2020
  51. Taylor BlauJul 10, 2020
  52. SZEDER GáborJul 15, 2020
  53. Derrick StoleeJul 15, 2020
  54. Junio C HamanoJul 15, 2020
  55. 6/8 commit-graph.c: simplify 'fill_oids_from_commits'Taylor Blau, May 13, 2020
  56. 7/8 t5318: reorder test below 'graph_read_expect'Taylor Blau, May 13, 2020
  57. 8/8 commit-graph: drop COMMIT_GRAPH_WRITE_CHECK_OIDS flagTaylor Blau, May 13, 2020
  58. Jeff KingMay 14, 2020
  59. Jeff KingMay 14, 2020

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.