From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-b6-smtp.messagingengine.com (fout-b6-smtp.messagingengine.com [202.12.124.149]) (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 2241A21CFE0 for ; Fri, 28 Aug 2026 22:51:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.149 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787957465; cv=none; b=DwUukWSAWGacU/buQ7J+vqrldvnR6mUDqROu23LNl+I3UtzUkgj5LhmLQJiXPwAFlEYYmRRTjQyMka6LcX2aR0s7Kb9zlioAQrnsrzHu/bNDDLXCNFU90ZO9BnzqA+L8TzYPb1bZwfAM6l2zaIKAH6pXHDb9anZt9z+NV6cfj7U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787957465; c=relaxed/simple; bh=J2xZ2okoGyQmlKXt6SPXT+g8/qYEhFm0iSoN2jjfCo8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=cNstphmjqSwAaZKkdmbaJ0TPV3r+Hw2/jmGbNj+SDv5HlcrWJKyHcEy/a3rogvM2WG/t6J7ZjhlbxxE73ZArIW0mRfQmFDHH9e1yHmBJTn9vPJ9ZWqbXksXW+n6VmNG3IzsoDDtla48PQwSB6YeytQ+pi/qAOs31/jHsP/fdFo0= 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=kWcqo+8B; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=mfnnRrk5; arc=none smtp.client-ip=202.12.124.149 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="kWcqo+8B"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="mfnnRrk5" Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfout.stl.internal (Postfix) with ESMTP id 09E3C1D00169; Fri, 28 Aug 2026 18:51:02 -0400 (EDT) Received: from phl-frontend-02 ([10.202.2.161]) by phl-compute-09.internal (MEProxy); Fri, 28 Aug 2026 18:51:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-transfer-encoding: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=1787957461; x=1788043861; bh=oy2NJsuXh7Cr+xJ1G0dJbMlKOo1msjjS/GCU4Aw93zE=; b= kWcqo+8BxJiLyav2zQQIEiIXtsz7/qXi57LX1EEqmPjh14FDH4Lrg8eaIkabcHkO UjK5W+WS8LEN6O+ofSZnXQ9zDU5OmwFqAtzT44/x/VWwO4n0/Ejdj4mpimjnplyL ZxDG9onbbOgMqAhK+46MjJadJWhScRnoOjmg80VtzAu4ZJkDXGsZzB83SvNrSzP0 No3mLGyvo8n+/ZusIOYdonFthUieT5HQ9FS7AD7Vj2hTZe2dXT+MiiZYhiG9lwKw fNnBISbknU3ScEBMxjqsMeISGNETVg9jVbPNCaoOAl1z+Vt/tgZd/Qldp3QtSPvi P8D21gKBbJ3SQ9AL5Kt7LA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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;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RxsVJZj xUJDfdUrGHW0C3kTwXVBX8WnGj3t1s9Pd4b5b2e8iJ0WynO2Oflgq6ENSEUQ X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 28 Aug 2026 18:51:01 -0400 (EDT) From: Junio C Hamano To: "D. Ben Knoble" Cc: Hardik Kumar , git@vger.kernel.org Subject: Re: [PATCH] builtin: replace the_repository parameter in is_bare_repository() In-Reply-To: (D. Ben Knoble's message of "Fri, 28 Aug 2026 07:41:39 -0400") References: Date: Fri, 28 Aug 2026 15:51:00 -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; charset=utf-8 Content-Transfer-Encoding: 8bit "D. Ben Knoble" writes: >> > 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. > > Sensible. Thanks! I actually answered a wrong question though ;-) The way cmd_switch() and cmd_restore() were introduced by sharing what used to serve cmd_checkout() was serviceable, but ugly. Had we started from separate implementations for 'switch' and 'restore' that were later merged into 'checkout', we would not have ended up with a design centered on a single monolithic choke point like checkout_main(). That is what I meant by "cheating instead of refactoring reusable parts". However, that is not directly relevant to your example. It is an anti-pattern to call the top-level implementation of 'git foo' in cmd_foo() directly from cmd_bar(), since these cmd_foo() functions are like main() in ordinary programs, performing one-time initialization (such as git_config() calls) and finalization that cannot be repeated. To help our codebase, as well as the use case you imagined in your message, it would help to trim down these non-reusable cmd_foo() implementations by turning them into mere orchestrators that call refactored helper functions. Such a change would put cmd_foo() and a client that wants to reuse 'git switch' functionality on the same footing, allowing more of our code to be used in different contexts. I think that is what people mean by the "libification" effort.