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

Re: [PATCH v5 1/2] pack-objects: give fetch_if_missing call sites access to 'repo'

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 14, 2026, 14:38 UTC
Message-ID
<xmqq7blsrclt.fsf@gitster.g>
In-Reply-To
<20260814072419.1666358-2-cat@malon.dev>
Tian Yuchen <cat@malon.dev> writes:
> 'option_parse_missing_action()' is registered as an OPT_CALLBACK, so
> its signature is fixed and cannot easily gain a 'repo' parameter of
> its own.

Is that true? OPT_CALLBACK takes (short, long, value, arghelp, help, callback), but the value parameter, which typically receives the location to store the parsed value in, is NULL for "--missing=<...>" option, like so:

		OPT_CALLBACK_F(0, "missing", NULL, N_("action"),
		  N_("handling for missing objects"), PARSE_OPT_NONEG,
		  option_parse_missing_action),

And "value" does not have to be the exact location; we can pass the address of the repository instance there, and the callback can dereference it to reach repo->fetch_if_missing member to make an assignment, if it wants to.

Am I missing something?
> Let it only record 'arg_missing_action'. Instead, apply the
> side effect right after 'parse_options()' returns in
> 'cmd_pack_objects()', where 'repo' is available.

When I review a new iteration, I first apply and look at the difference from the previous iteration before reading the new iteration of patches or their proposed commit log messages, and I did notice this business about "arg_missing_action" and wondering what it was about (which by the way is precisely I read the patch before the log message to ensure that the log message explains what I find unclear in the code). Thanks for describing this. But if we use OPT_CALLBACK() to pass the location of the variable, this may no longer be necessary, no?

Previous: Tian YuchenNext: Tian Yuchen
Message 20 of 26 in “repository: move fetch_if_missing into struct repository”
  1. repository: move fetch_if_missing into struct repositoryTian Yuchen, Jul 15, 2026
  2. Junio C HamanoJul 15, 2026
  3. Tian YuchenJul 15, 2026
  4. Patrick SteinhardtJul 15, 2026
  5. Tian YuchenJul 16, 2026
  6. Junio C HamanoJul 16, 2026
  7. repository: move fetch_if_missing into struct repositoryTian Yuchen, Jul 16, 2026
  8. Tian YuchenAug 1, 2026
  9. Patrick SteinhardtAug 4, 2026
  10. Junio C HamanoAug 4, 2026
  11. Tian YuchenAug 5, 2026
  12. Tian YuchenAug 5, 2026
  13. repository: move fetch_if_missing into struct repositoryTian Yuchen, Aug 7, 2026
  14. Junio C HamanoAug 7, 2026
  15. Tian YuchenAug 9, 2026
  16. repository: move fetch_if_missing into struct repositoryTian Yuchen, Aug 13, 2026
  17. Junio C HamanoAug 13, 2026
  18. 0/2 repository: move fetch_if_missing into struct repositoryTian Yuchen, Aug 14, 2026
  19. 1/2 pack-objects: give fetch_if_missing call sites access to 'repo'Tian Yuchen, Aug 14, 2026
  20. Junio C HamanoAug 14, 2026
  21. Tian YuchenAug 15, 2026
  22. 2/2 repository: move fetch_if_missing into struct repositoryTian Yuchen, Aug 14, 2026
  23. Junio C HamanoAug 14, 2026
  24. repository: move fetch_if_missing into struct repositoryTian Yuchen, Aug 15, 2026
  25. Junio C HamanoAug 15, 2026
  26. Tian YuchenAug 16, 2026

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.