Subject: Re: [GSoC RFC PATCH v2 0/7] repo-info: add new command for retrieving repository info

From: Junio C Hamano <[email-masked]>
Date: Tue, 24 Jun 2025 06:43:14 -0700

Phillip Wood <[email-masked]> writes:

> The reason git uses NUL termination for other commands is to prevent
> breaking the output when values contain newlines. The output format
> I'm suggesting is
>
>     <key><LF><value><NUL>
>
> so the output for "path.git-dir" written as a C string would be
>
>     "path.git-dir\n/home/phil/src/git/.git\0"
>
> The value can safely contain newlines because it is terminated by
> '\0'. The reason that "git config --list -z" exists is to provide an
> unambiguous output format as config values can contain newlines.

For Lukas's purpose, I presume we are in full control of keys, and
can assume that keys do not have any LF in them, so it is safe to
treat everything after the first LF up to the NUL as its value.  

Similarly, even though "config" allows essentially any byte value in
its second level component name in three component variable names,
we do not allow LF or NUL in it, so we are safe there too.

Thanks.