Re: [PATCH v3 3/3] config: allow overriding of global and system configuration
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 12, 2021, 17:04 UTC
- Message-ID
- <xmqq4kgbfn8o.fsf@gitster.g>
- In-Reply-To
- <af663640ae25a95fa56adf32baf4c2e197f3eea2.1618238567.git.ps@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 8 quoted lines
> char *git_system_config(void)
> {
> + char *system_config = xstrdup_or_null(getenv("GIT_CONFIG_SYSTEM"));
> + if (system_config) {
> + if (!strcmp(system_config, "/dev/null"))
> + FREE_AND_NULL(system_config);
> + return system_config;
> + }I am not sure if returning NULL from this function will always be the same as returning /dev/null on a system with functioning /dev/null. For example, when use_system_config is enabled, builtin/config.c::cmd_config() assigns the NULL returned by this function to given_config_source.file and then calls config.c::config_with_options(), which notices that none of use_stdin, file, or blob member of the config_source exists and falls back to the config_sequence().
So, for the purpose of special casing "/dev/null" textually, the above is not sufficient, I am afraid.
Let's rescind the "/dev/null gets turned into NULL" in the above change for now. If we truly want to cater to an installation where open("/dev/null") fails and emulate, that needs to be done at a much lower layer, but we do not have to go there for the purpose of this series.
Thanks.