Re: [PATCH] builtin: replace the_repository parameter in is_bare_repository()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 27, 2026, 21:39 UTC
- Message-ID
- <xmqqik4v6y6i.fsf@gitster.g>
- In-Reply-To
- <F276C11F-1904-496E-AA77-953724362C9A@gmail.com>
Ben Knoble <ben.knoble@gmail.com> writes:
Show 19 quoted lines
>> Le 27 août 2026 à 16:30, Junio C Hamano <gitster@pobox.com> a écrit : >> >> "Hardik Kumar" <hardikxk@gmail.com> 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.