Re: [PATCH v2 1/4] odb: decouple source path comparisons from `the_repository`

Patrick Steinhardt <[email protected]>
Newsgroups org.kernel.vger.git
Message-ID <[email protected]>
On Thu, Aug 13, 2026 at 05:23:39AM -0700, Karthik Nayak wrote:
> Patrick Steinhardt <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.