From: Toon Claes <toon@iotcl.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] replay: support replaying down from root commit
Date: Tue, 24 Mar 2026 18:25:13 +0100 [thread overview]
Message-ID: <87qzp916o6.fsf@iotcl.com> (raw)
In-Reply-To: <xmqqwlzajkha.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
> Toon Claes <toon@iotcl.com> writes:
>
>> git-replay(1) doesn't allow replaying commits all the way down to the
>> root commit. Fix that.
>
> OK.
>
>> - base = pickme->parents->item;
>> - replayed_base = mapped_commit(replayed_commits, base, onto);
>> + if (pickme->parents) {
>> + base = pickme->parents->item;
>> + replayed_base = mapped_commit(replayed_commits, base, onto);
>> + base_tree = repo_get_commit_tree(repo, base);
>
> So, if we are replaying a commit with parent(s), we do the same as
> before (base_tree used to be computed a bit later). But ...
>
>> + } else {
>> + base = NULL;
>> + replayed_base = onto;
>> + base_tree = lookup_tree(repo, repo->hash_algo->empty_tree);
>> + }
>
> ... if we are replaying the root commit, there is no base (in
> contrast to "the first parent of the original commit" used in the
> other branch of this if-else construct). We use an empty tree for
> the base_tree, which is the natural thing to use to replay for a
> root commit, of course.
>
> I am not sure why replayed_base is computed differently, though? Is
> it because mapped_commit() would not work when base==NULL?
That's correct, mapped_commit() dereferences commit->object.oid.
> I have to wonder if the handling of that case should also be
> encapsulated inside mapped_commit() helper, just like the helper
> knows to "fallback" when the commit is not yet mapped
I'm fine either way, so I'll do that in v2.
> After all, if we drive that line of thought to the extreme, we would
> end up making repo_get_commit_tree() to return an empty tree object
> for base==NULL, too, which may be logical but it is probably too much.
Well, it's a bit annoying `struct commit::parents` is a `struct
commit_list`, so we have to first check that pointer before we can
dereference `item`, so that guard do we need anyway. So I agree it's too
much.
One other thing, in v2 I'm also fixing the merge ancestor label. For
root commits it will say "empty tree" instead of "parent of <commit>",
so conflict messages aren't misleading.
--
Cheers,
Toon
next prev parent reply other threads:[~2026-03-24 17:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-17 18:56 [PATCH] replay: support replaying down from root commit Toon Claes
2026-03-17 19:59 ` Junio C Hamano
2026-03-24 17:25 ` Toon Claes [this message]
2026-03-24 19:35 ` [PATCH v2] " Toon Claes
2026-03-24 19:53 ` Junio C Hamano
2026-03-25 10:00 ` Christian Couder
2026-03-25 12:19 ` Ben Knoble
2026-03-25 15:35 ` Make git-replay(1) warn if revision-range isn't a range (was: Re: [PATCH v2] replay: support replaying down from root commit) Toon Claes
2026-03-25 15:32 ` [PATCH v2] replay: support replaying down from root commit Toon Claes
2026-03-25 15:37 ` Toon Claes
2026-03-27 16:45 ` Junio C Hamano
2026-03-25 16:49 ` 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=87qzp916o6.fsf@iotcl.com \
--to=toon@iotcl.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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