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

Re: [PATCH v2] commit: remove padding from struct commit

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 13, 2026, 17:13 UTC
Message-ID
<xmqq7bigfydc.fsf@gitster.g>
In-Reply-To
<pull.2309.v2.git.1794576606249.gitgitgadget@gmail.com>

"Kristofer Karlsson via GitGitGadget" <gitgitgadget@gmail.com> writes:

> Since the order of the members no longer reflects their importance,
Micronit: "no longer reflects logical grouping or impotance" or
something, just like you already have in the comment in the header
file.
Show 18 quoted lines
> diff --git a/commit.h b/commit.h
> index 1061ed791b..d43cb1e46d 100644
> --- a/commit.h
> +++ b/commit.h
> @@ -23,10 +23,30 @@ struct commit_list {
>   * The size of this struct matters in full repo walk operations like
>   * 'git clone' or 'git gc'. Consider using commit-slab to attach data
>   * to a commit instead of adding new fields here.
> + *
> + * The order of the members is partly chosen to keep the memory layout
> + * compact (avoiding alignment padding), and does not necessarily
> + * reflect their importance or grouping.
>   */
>  struct commit {
> +	/*
> +	 * Must be the first member, so that a "struct object *" can be
> +	 * cast to a "struct commit *".
> +	 */

Either append "... when we know it is a commit", swap the order, or do both. My preference is the second one which would leave the shortest result.

Show 7 quoted lines
>  	struct object object;
> +
> +	/*
> +	 * Index into the commit-slab arrays: unique per in-core commit,
> +	 * and only meaningful within the current process.
> +	 */
> +	unsigned int index;

Nice. It is on a rather longer side and "and only meaningful..." may be redundant after saying "in-core", but nothing is wrong.

Thanks.  Will queue.
Previous: Junio C HamanoNext: Kristofer Karlsson via GitGitGadget
Message 11 of 12 in “commit: remove padding from struct commit”
  1. commit: remove padding from struct commitKristofer Karlsson via GitGitGadget, Nov 12, 2026
  2. Derrick StoleeNov 12, 2026
  3. Kristofer KarlssonNov 12, 2026
  4. Junio C HamanoNov 12, 2026
  5. Kristofer KarlssonNov 12, 2026
  6. Oswald BuddenhagenNov 13, 2026
  7. commit: remove padding from struct commitKristofer Karlsson via GitGitGadget, Nov 13, 2026
  8. Derrick StoleeNov 13, 2026
  9. Kristofer KarlssonNov 13, 2026
  10. Junio C HamanoNov 13, 2026
  11. Junio C HamanoNov 13, 2026
  12. commit: remove padding from struct commitKristofer Karlsson via GitGitGadget, Nov 15, 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.