Re: [PATCH v8 4/9] environment: move pager_program into repo_config_values
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 9, 2026, 16:41 UTC
- Message-ID
- <xmqqpl0wp141.fsf@gitster.g>
- In-Reply-To
- <0da20189-4e5b-4af0-b504-e99ac16d40af@malon.dev>
Tian Yuchen <cat@malon.dev> writes:
Show 37 quoted lines
>>> if (!strcmp(var, "core.pager"))
>>> - return git_config_string(&pager_program, var, value);
>>> + return git_config_string(&repo_config_values(r)->pager_program, var, value);
>>
>> Isn't this still overwriting what was in the .pager_program member
>> of the config values struct? In check_pager_config() below, there
>> is a free() to avoid such a leak, but wouldn't this have the same
>> issue?
>>
>>> @@ -91,10 +94,10 @@ const char *git_pager(struct repository *r, int stdout_is_tty)
>>>
>>> pager = getenv("GIT_PAGER");
>>> if (!pager) {
>>> - if (!pager_program)
>>> + if (!repo_config_values(r)->pager_program)
>>> read_early_config(r,
>>> - core_pager_config, NULL);
>>> - pager = pager_program;
>>> + core_pager_config, r);
>>> + pager = repo_config_values(r)->pager_program;
>>> }
>>> if (!pager)
>>> pager = getenv("PAGER");
>>> @@ -302,7 +305,9 @@ int check_pager_config(struct repository *r, const char *cmd)
>>>
>>> read_early_config(r, pager_command_config, &data);
>>>
>>> - if (data.value)
>>> - pager_program = data.value;
>>> + if (data.value) {
>>> + free(repo_config_values(r)->pager_program);
>>> + repo_config_values(r)->pager_program = data.value;
>>> + }
>>> return data.want;
>>> }
>
> Nice catch, sorry for missing that!You do not have to be or say sorry. This is a team effort, and I am reasonably sure that I did not catch _all_ similar bugs in this iteration. So before you send an updated version, please make sure that you just do not fix this one only and be content with it. Instead try to see if there are other similar issues and fix them, too.
Thanks.