From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-a6-smtp.messagingengine.com (fout-a6-smtp.messagingengine.com [103.168.172.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 BC162379EC8 for ; Thu, 27 Aug 2026 20:28:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.149 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787862529; cv=none; b=gRblQh+7p2Cn1S91TgERKj8Xxoysx6ILSce4KmGTHQRpoGvLdk2/omtq/oUcBgsiEsgs+7VI+mCXI57ywLgSSo3h8JdLz+yZ+wyhZG8gFPSCWQOuz47xd1eektNIaQFvQJJ5dp+L5gSaxJOUXYqH6IekfXcr5ALJw6Xafllhz6U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787862529; c=relaxed/simple; bh=0VSYaHposUdaVXjf6RRmKcXP+9jy8qBxtG3JDm55DbY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=U3qxlt/CT3qpUI+pQYoP5D+tCKdt1As+w51fznCo4LdAXCVlyvG/1k0bzlaoKk+yZ/0DKUfpn1XODPAL416HZRmvFmWYOSVIP0pyYywWyFa+GL0toThr21mc6jm172Z02jAOAnqVNSh3ifiTnfw62DGjKCRCyOc4tSbUD5+R1C4= 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=RiIU9baC; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=lia9SNQ8; arc=none smtp.client-ip=103.168.172.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="RiIU9baC"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="lia9SNQ8" Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id 34375EC0100; Thu, 27 Aug 2026 16:28:45 -0400 (EDT) Received: from phl-frontend-01 ([10.202.2.160]) by phl-compute-01.internal (MEProxy); Thu, 27 Aug 2026 16:28:45 -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=1787862525; x=1787948925; bh=O/7i1E4lpS zeozKYNRa08E31U1ecUmVrHqoE9/Teyuo=; b=RiIU9baCow9rL9R2XLjMCXI5nn TtLlUOUVVg2n06qVt0ApX9qAx6LEM2SGobmKwKrjZyz2pvN9A2MKVWGGuRjkDow4 2DjF45QJadNv09dzrGRRyyva8QTYWzpAKSBRzAlABFf5MTJwRduCDKXwk0Hbbx7h GUzn3nBQq6CqZlCANyIgpKZoaAV/x6i0fmOIHrZ6JuLu07yzZlpwHjrqyT6qhZLu DSMfP6qXnj6mQsolrixtb+mrBmJtNeMLHSr+iwC4x2YpfC3NE5donYaWtQhAtEMv 6CA/ZaPxaoUKKui9Onli0j0oaAOShjxn318iv1KWjP0qUoJoZbDn+7Hvpbtg== 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= 1787862525; x=1787948925; bh=O/7i1E4lpSzeozKYNRa08E31U1ecUmVrHq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rx1IeVGKgm9Q X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 27 Aug 2026 16:28:44 -0400 (EDT) From: Junio C Hamano To: "Hardik Kumar" Cc: Subject: Re: [PATCH] builtin: replace the_repository parameter in is_bare_repository() In-Reply-To: (Hardik Kumar's message of "Fri, 28 Aug 2026 01:39:43 +0530") References: <20260827-env-is_bare_repo-v1-1-aa99600dc213@gmail.com> Date: Thu, 27 Aug 2026 13:28:43 -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: >> 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"). > > Right, but would safety check be required for single instance or better > to find and work on only the specific ones which could lead to an > exception. I do not quite get what you mean. In a single function you use the_repository and repo interchangeably, relying on repo, when it is not NULL), being the same as the_repository for correctness. If they ever refer to different things, then your updated code is less consistent than the original, which would not be an improvement. I actually think a good medium size project is to fix the last parameter given to cmd_foo() built-in command implementations that is a pointer to "struct repository". It was a misguided design. This pointer is either NULL or the_repository; it never takes any other value. It is misleading and invites confusion that these functions can take arbitrary repository instance. It also invites people to replace all references in cmd_foo() to "the_repository" with "repo", which may lead to an error. Depending on where parse_options() call appears in the cmd_foo(), "cd / && git foo -h" will cause segfaults with such a change. If we change the function signature of cmd_foo() to receive a "bool" that says "true" if the command was run inside a repository and "false" otherwise, cmd_foo() can still tell if the command was run outside a repository, and programmers will not be misled to use anything other than "the_repository" as the repository to work on. 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.