Re: [PATCH v5 3/6] set-head: better output for --auto
- From
Bence Ferdinandy <bence@ferdinandy.com>
- Date
- Oct 10, 2024, 19:08 UTC
- Message-ID
- <D4SD24J4X5ET.34TQIQDDCX8E@ferdinandy.com>
- In-Reply-To
- <xmqqv7y0lzn5.fsf@gitster.g>
On Thu Oct 10, 2024 at 17:57, Junio C Hamano <gitster@pobox.com> wrote:
Show 22 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Bence Ferdinandy <bence@ferdinandy.com> writes:
>>
>>> +static void report_auto(const char *remote, const char *head_name,
>>> + struct strbuf *buf_prev) {
>>> + struct strbuf buf_prefix = STRBUF_INIT;
>>> + const char *prev_head;
>>
>> I think we need to initialize prev_head to NULL.
>>
>>> + strbuf_addf(&buf_prefix, "refs/remotes/%s/", remote);
>>> + skip_prefix(buf_prev->buf, buf_prefix.buf, &prev_head);
>>
>> If the symref was not pointing into the "refs/remotes/<remote>/"
>> hierarchy previously, skip_prefix() comes back without touching
>> prev_head (i.e. not starting with the prefix does not clear it).
>
> The two uninitialized prev_head were also noticed by compilers in
> multiple jobs at GitHub CI.
>
> https://github.com/git/git/actions/runs/11265515664I wonder why that didn't fail the build for me locally. I was running
make -j8 install PREFIX=$HOME/.local
for testing. Should I have added a flag or ENV variable somewhere?
Anyhow, the v6 I sent earlier today should fix this (and hopefully all your other comments as well).
Thanks, Bence
-- bence.ferdinandy.com