Re: [PATCH v2 1/4] odb: decouple source path comparisons from `the_repository`
Karthik Nayak <[email protected]>
| Newsgroups | org.kernel.vger.git |
|---|---|
| Message-ID | <CAOLa=ZQARq2eoVegh1BsnKrvd9MuraNFJ3htKDxQ5H25WJUs1w@mail.gmail.com> |
Patrick Steinhardt <[email protected]> writes: > 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 Ooh, yes, makes sense. It's better as is :)
signature.asc
(application/pgp-signature, 690 B)
-----BEGIN PGP SIGNATURE----- iQHKBAEBCgA0FiEEV85Mf2N1cQ/LZcYGPtWfJI5GjH8FAmp+7EAWHGthcnRoaWsu MTg4QGdtYWlsLmNvbQAKCRA+1Z8kjkaMf2dpC/9Lwtf/COLSCdoJFAK5NbEVY1X+ DEjf25IL3tBHYcH0XrFu0LCiXt0tSFNKEkhJZ0HVK+SxCAaFaX5PM6hVq5OHGo+p asN+ypzOLqdjZiIoLejhb2Yi3y7ciZ7lBNXqwQ599/iIXvVyFsIMwKh2ERoyQlLS wnObpV4eXfRwA3/56bOA30sf+5IjwCpok8OEhm/lcqdWe+dJo2MBQPwz7M54cahg KqyAEYgbZ0NOnjBtIYNOT7iijI0lP1ZD3j4K0ZSjjWTNyTY5uSEaSTYFEm8rUzSy beL73N1Ab76g8cGC1c8z0hVHetz42BYVKFqbww/wEYbhgu2OuzF2g4dMJbFnID7y sK9h+NvwfDAx5qX3y50M/A1zrIYGQMHV85xl9gc24rzazVay8+S/uuzeyH0jYPxP 2qeiHPxHoleXViN4UCQnrjTgV39uBp0/UHZ945Y4m4YBcae/H2N1MWQRvwKgDk0E WeQWp7Eo6aEs+7kutMDNIfKdm+juAZtFHLpJpu4= =Zr+E -----END PGP SIGNATURE-----