From: Junio C Hamano Date: Fri, 28 Aug 2026 20:59:55 GMT Subject: Re: [PATCH] do not pass "repo" to builtin commmand implementations Message-ID: In-Reply-To: "Hardik Kumar" writes: > This would certainly help make it more obvious as not use the pointer > parameter. But would you not consider to eventually move towards > something more efiicient in the future? It is unclear what kind of more efficient alternative you have in mind. The primary motivation for this change is to make the implementation of built-in commands less error-prone and harder to abuse. The implementation of 'git foo' in cmd_foo() in builtin/foo.c performs one-time initialization (such as calling git_config()) and finalization that cannot be repeated, making it an anti-pattern to call cmd_foo() from within cmd_bar(). Refraining from pretending these functions can operate on an arbitrary caller-supplied repository instance is one step toward preventing such misuse. However, another motivation for this change is to encourage developers who want to aid the libification effort to refactor code out of cmd_foo() into reusable helper functions. Instead of keeping those helpers within builtin/foo.c, they can be moved to library files outside the builtin/ directory and take a pointer to 'struct repository'. The top-level cmd_foo() can still access 'the_repository' directly and orchestrate the execution of 'git foo' by passing a pointer to these helper functions. That way, more code becomes reusable.