Re: [PATCH 3/3] environment: reorder variables in repo_config_values structure
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 6, 2026, 16:42 UTC
- Message-ID
- <xmqq5x1nmc90.fsf@gitster.g>
- In-Reply-To
- <dbcbb042-5c50-4569-9b18-3edcc7b1ef4b@malon.dev>
Tian Yuchen <cat@malon.dev> writes:
Show 34 quoted lines
> On 8/6/26 05:47, Junio C Hamano wrote: >> Tian Yuchen <cat@malon.dev> writes: >> >>> Reorder the fields in struct repo_config_values and its initialization >>> function to follow the order of configuration sections. >>> >>> Keeping the declaration and initialization order aligned makes the >>> structure easier to review and maintain. >> >> Really? >> >> Do you have some automated tool to make sure these initialization >> assignments in the environment.c file and declaration in the >> environment.h file match the order in Documentation/config/*.adoc or >> something else? Have you designated some list as the authoritative >> source of truth to check these against? Without such a list to >> check the code against and a mechanism to enforce the ordering, I >> find it hard to agree with such a claim that this makes it easier to >> maintain. > > I see. > >> >> It is typical to list the structure members in the order of stricter >> to looser alignment requirement of their types. I do not know how >> strictly it is followed for "struct repo_config_values", but by >> spreading pointer valued members more widely with smaller enums in >> between, the change certainly is making the overall structure size >> larger by requiring more padding between the members with different >> alignment requirements. Not that we would have 100s of instances of >> these structures. >> > > Oh, I overlooked the size issue. Thanks for pointing out.
I didn't mean to "point out" any size issue. As I said, it is not like we have hundreds of these, so padding bloat here and there would not matter and if we get a readability boost by reordering into a sensible order, that by itself could be a win.