From: Junio C Hamano Date: Fri, 13 Nov 2026 16:52:48 GMT Subject: Re: [PATCH v2] commit: remove padding from struct commit Message-ID: In-Reply-To: Kristofer Karlsson writes: > On Fri, 13 Nov 2026 at 15:57, Derrick Stolee wrote: >> >> On 11/13/2026 8:30 AM, Kristofer Karlsson via GitGitGadget wrote: >> > From: Kristofer Karlsson >> >> > struct commit { >> > + /* >> > + * Must be the first member, so that a "struct object *" can be >> > + * cast to a "struct commit *". >> > + */ >> > struct object object; >> >> I think your comment is backwards: We cast a commit into an object >> and it works. We can't cast an arbitrary object to a commit. I had the exact reaction. In our "cheap C inheritance" pattern downcasting commit to object can be done unconditionally, but upcasting needs to be done with out of band knowledge (because these struct types do not have "type" signature). So ... so that a "struct commit *" can be cast to a "struct object *". The code casts in other direction only when the object is known to be a commit.