Re: [RFC PATCH 1/3] Make read_gitfile and resolve_gitfile thread safe
On Mon, Mar 4, 2024 at 8:29 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
> Style: Declare `resolved_gitdir_buf` along with `ret` and `gitdir`,
> then have a blank line before the actual code.
Thanks for the detailed style feedback.
Show 9 quoted lines
>
> > } else if (err == READ_GITFILE_ERR_NOT_A_REPO) {
> > - if (!(backlink = infer_backlink(realdotgit.buf))) {
> > + if (!(backlink.buf = infer_backlink(realdotgit.buf))) {
>
> Don't do this. Never modify the internal state of strbuf directly;
> consider the state read-only. Modifications should only be made via
> the API. You'll need to rewrite this code a bit to make it work
> correctly with the changes proposed by this patch.Good catch, I should've paid more attention in the refactoring.
Fixed all of the discussed notes in v2.