Thread (47 messages) flat view 47 messages, 4 authors, 21d ago

Re: [PATCH] builtin: replace the_repository parameter in is_bare_repository()

From: Junio C Hamano <hidden>
Date: 2026-08-27 21:39:04

Ben Knoble [off-list ref] writes:
quoted
Le 27 août 2026 à 16:30, Junio C Hamano [off-list ref] a écrit :

"Hardik Kumar" [off-list ref] writes:
quoted
quoted
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]
quoted
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help