Re: [PATCH v2 1/4] odb: decouple source path comparisons from `the_repository`
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Aug 13, 2026, 13:17 UTC
- Message-ID
- <an3DzPKAFqygOS65@pks.im>
- In-Reply-To
- <CAOLa=ZTsumAT6U8+pJQmNjYL6Rt=JkvTJ0V7KQ7MvLYkThTFYA@mail.gmail.com>
On Thu, Aug 13, 2026 at 05:23:39AM -0700, Karthik Nayak wrote:
Show 25 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> > diff --git a/odb.c b/odb.c
> > index bd02d8ad54..51da386f22 100644
> > --- a/odb.c
> > +++ b/odb.c
> > @@ -29,8 +28,32 @@
> > #include "trace2.h"
> > #include "write-or-die.h"
> >
> > -KHASH_INIT(odb_path_map, const char * /* key: odb_path */,
> > - struct odb_source *, 1, fspathhash, fspatheq)
> > +static int odb_source_paths_cmp(struct object_database *o,
> > + const char *a, const char *b)
> > +{
> > + if (o->source_paths_icase < 0) {
> > + int icase = 0;
> > + repo_config_get_bool(o->repo, "core.ignorecase", &icase);
> > + o->source_paths_icase = icase;
> > + }
> > +
>
> Nit: couldn't this be simplified to
>
> if (o->source_paths_icase < 0)
> repo_config_get_bool(o->repo, "core.ignorecase", &o->source_paths_icase);Not quite, as that wouldn't handle the case where the configuration isn't set. So we'd retain it as -1 and do the config lookup every single time.
We could rewrite like this:
if (o->source_paths_icase < 0 && repo_config_get_bool(o->repo, "core.ignorecase", &icase)) o->source_paths_icase = 0;
But I'd argue that this is harder to read.
Patrick