Re: [PATCH 0/6] [RFC] config.c: use struct for config reading state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> writes:

>> Yes, exactly. Having a config_set on the repository makes sense, but I
>> don't see a good reason to have the reader on the repository.
>
> [...]
>
> I hadn't looked closely at this aspect of it, and just took it as a
> given that we needed to persist this data outside of the configset
> lifetime.

There really isn't a need to persist the "config_reader" state, we'd
only need it while reading the file, and as you've hinted, once we've
cached the info in the configset, we'd just use that instead.

> If that's not the case then we don't need it in the file scope, nor a
> "struct repository" or whatever, and could just have it materialized by
> git_config_check_init(), no? I.e. when we create the configset we'd
> create it, and throw it away after the configset is created?

Yes, except that I'm proposing that we should do it even lower in the
chain, like do_config_from().

> 	The catch (aka the reason I stopped halfway through) is that I
> 	couldn't find a way to expose "struct config_reader" state
> 	without some fairly big changes, complexity-wise or LoC-wise[...]
>
> I didn't look into exactly why config_fn_t would need your new "reader",

Ah, this is what I was referencing in the CL here:

  I believe that only config callbacks are accessing this [config
  reader] state, e.g. because they use the low-level information (like
  builtin/config.c printing the filename and scope of the value) or for
  error reporting (like git_parse_int() reporting the filename and line
  number of the value it failed to parse)

> but if you accept that we could stick such a thing into "the_repository"
> then there's no catch or need for the churn to change all those
> callbacks.
>
> Of course something that wants to use the API as a "real" library would
> need to use some alternate mechanism, as you reference in adding a new
> "config_state_fn_t". You note:
>
> 	but I couldn't find a great way to do this kind of 'switching
> 	between config callback types' elegantly.
>
> So, I don't know, but I was suggesting looking into doing that based on
> "the_repository" in play...

And yes, since the primary purpose is to make git_config_from_file()
usable by a library caller (and secondarily, prepare for a future where
reading config is thread-safer because of less global state, as Jonathan
discussed [1]), I'd prefer not to use the_repository.

1. https://lore.kernel.org/git/20230306195756.3399115-1-jonathantanmy@xxxxxxxxxx




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux