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

Re: [PATCH v2 1/5] submodule-config.h: remove unused SUBMODULE_INIT macro

From
Jeff King <peff@peff.net>
Date
Sep 27, 2021, 23:34 UTC
Message-ID
<YVJU89iekC0zZSkF@coredump.intra.peff.net>
In-Reply-To
<patch-v2-1.5-7a7a0141515-20210927T124407Z-avarab@gmail.com>
On Mon, Sep 27, 2021 at 02:54:24PM +0200, Ævar Arnfjörð Bjarmason wrote:
Show 20 quoted lines
> This macro was added and used in c68f8375760 (implement fetching of
> moved submodules, 2017-10-16) but its last user went away in
> be76c212823 (fetch: ensure submodule objects fetched, 2018-12-06).
> 
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  submodule-config.h | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/submodule-config.h b/submodule-config.h
> index c11e22cf509..65875b94ea5 100644
> --- a/submodule-config.h
> +++ b/submodule-config.h
> @@ -45,10 +45,6 @@ struct submodule {
>  	struct object_id gitmodules_oid;
>  	int recommend_shallow;
>  };
> -
> -#define SUBMODULE_INIT { NULL, NULL, NULL, RECURSE_SUBMODULES_NONE, \
> -	NULL, NULL, SUBMODULE_UPDATE_STRATEGY_INIT, { { 0 } }, -1 };

I was a bit surprised by this one, just because we generally prefer the builtin initializers to init functions. And even if we are only using the latter, I like the move to implementing it in terms of the former.

But this struct is extra funny, as now it will have neither. It comes only from submodule_from_name() or submodule_from_path(), which in turn are building up from config and the initialization in lookup_or_create_by_name(). And keeping those two in sync is potentially error-prone.

So this whole "make a submodule struct on the stack" thing is pretty odd in the first place, and I'm happy to see this initializer going away.

-Peff
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 22 of 32 in “Designated initializer cleanup & conversion”
  1. 0/5 Designated initializer cleanup & conversionÆvar Arnfjörð Bjarmason, Sep 27, 2021
  2. 2/5 *.[ch] *_INIT macros: use { 0 } for a "zero out" idiomÆvar Arnfjörð Bjarmason, Sep 27, 2021
  3. Eric SunshineSep 27, 2021
  4. Johannes SixtSep 27, 2021
  5. Junio C HamanoSep 27, 2021
  6. 1/5 submodule-config.h: remove unused SUBMODULE_INIT macroÆvar Arnfjörð Bjarmason, Sep 27, 2021
  7. 3/5 *.h _INIT macros: don't specify fields equal to 0Ævar Arnfjörð Bjarmason, Sep 27, 2021
  8. 5/5 cbtree.h: define cb_init() in terms of CBTREE_INITÆvar Arnfjörð Bjarmason, Sep 27, 2021
  9. Johannes SixtSep 27, 2021
  10. Ævar Arnfjörð BjarmasonSep 27, 2021
  11. Jeff KingSep 27, 2021
  12. Johannes SixtSep 28, 2021
  13. Junio C HamanoSep 28, 2021
  14. Ævar Arnfjörð BjarmasonSep 28, 2021
  15. Junio C HamanoSep 28, 2021
  16. Phillip WoodSep 27, 2021
  17. Ævar Arnfjörð BjarmasonSep 27, 2021
  18. Phillip WoodSep 30, 2021
  19. 4/5 *.h: move some *_INIT to designated initializersÆvar Arnfjörð Bjarmason, Sep 27, 2021
  20. 0/5 Designated initializer cleanup & conversionÆvar Arnfjörð Bjarmason, Sep 27, 2021
  21. 1/5 submodule-config.h: remove unused SUBMODULE_INIT macroÆvar Arnfjörð Bjarmason, Sep 27, 2021
  22. Jeff KingSep 27, 2021
  23. 2/5 *.[ch] *_INIT macros: use { 0 } for a "zero out" idiomÆvar Arnfjörð Bjarmason, Sep 27, 2021
  24. Jeff KingSep 27, 2021
  25. Ævar Arnfjörð BjarmasonSep 28, 2021
  26. Jeff KingSep 28, 2021
  27. Ramsay JonesSep 28, 2021
  28. 3/5 *.h _INIT macros: don't specify fields equal to 0Ævar Arnfjörð Bjarmason, Sep 27, 2021
  29. Junio C HamanoSep 27, 2021
  30. 4/5 *.h: move some *_INIT to designated initializersÆvar Arnfjörð Bjarmason, Sep 27, 2021
  31. Junio C HamanoSep 27, 2021
  32. 5/5 cbtree.h: define cb_init() in terms of CBTREE_INITÆvar Arnfjörð Bjarmason, Sep 27, 2021

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.