From: Kaartic Sivaraam Date: Fri, 25 Sep 2026 14:33:24 GMT Subject: Re: [RFC PATCH 3/3] setup: communicate why a directory is not a valid git directory Message-ID: In-Reply-To: On 9/25/26 03:46, Junio C Hamano wrote: > Kaartic Sivaraam writes: > >> + strbuf_addf(&die_msg, _("not a git repository: '%s'"), gitdirenv); >> + strbuf_addch(&die_msg, '\n'); >> + strbuf_addf(&die_msg, _("reason: %s"), invalid_gitdir_reason.buf); >> + die("%s", die_msg.buf); >> + >> + strbuf_release(&die_msg); > > You just called die(); nobody will execute this strbuf_release() for > you, and because die() is marked with NORETURN, smart enough compilers > would scold you for introducing dead code. > Oops. It should indeed warn me. I did a quick check and seems gcc (which I was using) lost its ability to report this long ago[1]. Sad. Clang clearly reports this. [1]: https://gcc.gnu.org/legacy-ml/gcc-help/2011-05/msg00360.html > Why are you lego-assembling localized message yourself, instead of > doing something like ... > > die(_("not a git repository: '%s'\nreason: %s"), > gitdirenv, invalid_gitdir_reason.buf); > > ... which is what is usually done? > That was my attempt at trying to save translators some work of translating the "not a git repository" part. I was thinking this lego was not a problem as it was not so complex. If we just want to avoid legos totally, I'm cool with doing it the usual way. -- Sivaraam