Re: [PATCH 2/4] real_path: remove unsafe API
On 06.03.2020 23:12, Junio C Hamano wrote:
Show 13 quoted lines
> If my reading of the code is correct, however, the first thing that
> is done by strbuf_realpath() is to empty the output buffer by using
> strbuf_reset() indirectly via get_root_part(). Calling strbuf_reset()
> here should not hurt, but it is unnecessary, I would think. An even
> worse effect such a redundant strbuf_reset() has is that by repeatedly
> seeing the "reset then call realpath" pattern, readers who do not read
> the implementation of strbuf_realpath() might mistakenly think that
>
> strbuf_addf(&message, "the path '%s' is really ", path);
> strbuf_realpath(&message, path);
>
> is how realpath() is expected to be used, i.e. keep the current
> contents in the buffer and append the resolved path to it.
Thanks, will change in V2 next week.