From: Patrick Steinhardt Date: Mon, 22 Jun 2026 13:53:42 GMT Subject: Re: [PATCH v4 2/3] replay: add helper to put entry into mapped_commits Message-ID: In-Reply-To: <20260622-toon-git-replay-drop-merges-v4-2-ff257f534319@iotcl.com> On Mon, Jun 22, 2026 at 02:41:56PM +0200, Toon Claes wrote: > diff --git a/replay.c b/replay.c > index 1f8e5b083b..7921d7dba3 100644 > --- a/replay.c > +++ b/replay.c > @@ -256,6 +256,21 @@ static struct commit *mapped_commit(kh_oid_map_t *replayed_commits, > return kh_value(replayed_commits, pos); > } > > +static void put_mapped_commit(kh_oid_map_t *replayed_commits, > + struct commit *commit, > + struct commit *new_commit) > +{ > + khint_t pos; > + int ret; > + > + pos = kh_put_oid_map(replayed_commits, commit->object.oid, &ret); > + if (ret == 0) > + BUG("Duplicate rewritten commit: %s\n", > + oid_to_hex(&commit->object.oid)); > + > + kh_value(replayed_commits, pos) = new_commit; > +} The khash map interfaces are quite awkward to use, so having a small wrapper feels sensible to me. It is one of those interfaces that really make you wish for generics in C. Patrick