From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-b5-smtp.messagingengine.com (fout-b5-smtp.messagingengine.com [202.12.124.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7B403DA7DB for ; Fri, 28 Aug 2026 20:59:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.148 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787950800; cv=none; b=XD68amWICDY9bF5geI9+/981OVX0VsITigUxrgmX2/BrICegZMNyKNUHbMVyaAIepz72GSseW7qNyPMC3XR8157OH1Wxw1My4bFJuKwX1Y4h+AHHnUlviAYh2wI0gg6+8UcAiObElzvyOGXjCEfBGD3dbN3k7FtF/ZyhZdlBJGg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787950800; c=relaxed/simple; bh=h2aB1RgvwokHqH0ETk2g7GF7QLrvJIbiTZhIpfFM39U=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=K5ryaqS9C3g3y9jd9c6P70BvEvD0OSbi1nUX9R3Kof9DPtVedVxqZ3Rr4R44FwpSAbUDoGdPPbTfpUwOh7qDISKvpYuykHt3WKoWRXQOmvZU9LQJsB9tiEwHdau3wO7mht7O2gt8Fk9RXS57FfEjVqm+x56Vcr1PeEokusbMJnA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=Ud56IHgl; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=IR5JO1bV; arc=none smtp.client-ip=202.12.124.148 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="Ud56IHgl"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="IR5JO1bV" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id 0ED411D00124; Fri, 28 Aug 2026 16:59:58 -0400 (EDT) Received: from phl-frontend-01 ([10.202.2.160]) by phl-compute-04.internal (MEProxy); Fri, 28 Aug 2026 16:59:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1787950797; x=1788037197; bh=MONItSSTBa av2Kn5t6ME6ltfQR7Q/IIGNuMr6u+Lz2Y=; b=Ud56IHglZQAkapJiZNNEwQFrzD N8q1T/3zEZcZxK0JGEBqsjdQlgl22HjSBLLQUSlkuKZMXn43/DEzXner3z7Ft2c1 wL+8PUhIt/4KV1+xvqIU/XEdT6Dz73fIS+qz9jZvr4yErsqmXef/NZmLiuIh6xcg UAyGl19aL3uQbh1S2xbs+uNapP03GrvxLFeVGzWVVEpx3Bgmcx0o0vvaSQYJnXFv fu8L5pHwYxbViWkzSxQWmwRhkEzVt+U+SftLsZDdO6mug96Iv+WwhddpuAkwKsMn X+7TWBeXejgVhqITJWQRXB9B/Mtrtxys77BN3P9s/JcellWr/v/xmE0FVDPA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1787950797; x=1788037197; bh=MONItSSTBaav2Kn5t6ME6ltfQR7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eO8DMo+7HTGWtbhEr3gZ2Q X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 28 Aug 2026 16:59:57 -0400 (EDT) From: Junio C Hamano To: "Hardik Kumar" Cc: Subject: Re: [PATCH] do not pass "repo" to builtin commmand implementations In-Reply-To: (Hardik Kumar's message of "Fri, 28 Aug 2026 14:35:47 +0530") References: <20260827-env-is_bare_repo-v1-1-aa99600dc213@gmail.com> Date: Fri, 28 Aug 2026 13:59:55 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain "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.