From: D. Ben Knoble Date: Fri, 28 Aug 2026 11:41:39 GMT Subject: Re: [PATCH] builtin: replace the_repository parameter in is_bare_repository() Message-ID: In-Reply-To: On Thu, Aug 27, 2026 at 5:39 PM Junio C Hamano wrote: > > Ben Knoble writes: > > >> Le 27 août 2026 à 16:30, Junio C Hamano a écrit : > >> > >> "Hardik Kumar" writes: > >> > >>>> In general, builtin/foo.c::cmd_foo() are concrete programs that work > >>>> on specific repository (i.e., the_repository), and there is not much > >>>> reason to rewrite the use of the_repository to use "repo" given by > >>>> the caller which is git potty. You'd also need to deal with the > >>>> case where "repo" is NULL (hint: "cd / && git foo -h"). > > > > [snip] > > > >> The utility functions builtin/foo.c borrows from outside builtin/ > >> directory are being "libified" to reduce the hardcoded dependence on > >> the_repository, and cmd_foo() can call these functions with > >> the_repository as a parameter. But we have no reason to waste our > >> time updating (and also reviewing patches that make such updates) > >> the built-in implementations themselves to take a pointer to an > >> arbitrary repository. > > Line wrap to reasonable length. Yeah… my iPhone (from which I sometimes reply) supports plaintext if I do things just right, but it doesn't wrap lines. It's difficult to judge where to break, but maybe I'll try hardbreaks every so often and see if that helps. > > Hm. What if a program wants to do « exactly what ‘git switch’ does > > » sans shelling out? > > Instead of cheating, properly factor out reusable part from > cmd_checkout() into a set of libified routines, and make both > cmd_checkout() and cmd_switch() to call them > > An approach like that would help "libify" things. libifying is not > just reducing dependence of globals. > > Calling main() from something else is not a libification. Sensible. Thanks! -- D. Ben Knoble