From: Junio C Hamano <gitster@pobox.com>
To: Kristofer Karlsson <krka@spotify.com>
Cc: Derrick Stolee <stolee@gmail.com>,
Kristofer Karlsson via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org
Subject: Re: [PATCH v2] commit: remove padding from struct commit
Date: Fri, 13 Nov 2026 08:52:48 -0800 [thread overview]
Message-ID: <xmqqbj7sfzbz.fsf@gitster.g> (raw)
In-Reply-To: <CAL71e4MZTKK3wmf4TM6DcZdc0-Bt91XaPTHy54rbYUmhNpWcbQ@mail.gmail.com> (Kristofer Karlsson's message of "Fri, 13 Nov 2026 16:41:41 +0100")
Kristofer Karlsson <krka@spotify.com> writes:
> On Fri, 13 Nov 2026 at 15:57, Derrick Stolee <stolee@gmail.com> wrote:
>>
>> On 11/13/2026 8:30 AM, Kristofer Karlsson via GitGitGadget wrote:
>> > From: Kristofer Karlsson <krka@spotify.com>
>>
>> > 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.
next prev parent reply other threads:[~2026-11-13 16:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 16:14 [PATCH] commit: remove padding from struct commit Kristofer Karlsson via GitGitGadget
2026-11-12 18:00 ` Derrick Stolee
2026-11-12 21:46 ` Kristofer Karlsson
2026-11-12 19:22 ` Junio C Hamano
2026-11-12 21:35 ` Kristofer Karlsson
2026-11-13 15:31 ` Oswald Buddenhagen
2026-11-13 13:30 ` [PATCH v2] " Kristofer Karlsson via GitGitGadget
2026-11-13 14:57 ` Derrick Stolee
2026-11-13 15:41 ` Kristofer Karlsson
2026-11-13 16:52 ` Junio C Hamano [this message]
2026-11-13 17:13 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqbj7sfzbz.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=krka@spotify.com \
--cc=stolee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox