From: Junio C Hamano Date: Thu, 27 Aug 2026 21:39:01 GMT Subject: Re: [PATCH] builtin: replace the_repository parameter in is_bare_repository() Message-ID: In-Reply-To: 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. > 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.