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 E95145013A9 for ; Wed, 30 Sep 2026 16:03:18 +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=1790784202; cv=none; b=evBf91GFo11YsFJAXL9hKeVLW+Yle46zVTC9XLrUTLRdEy77Kn5adOi78pWZUOW9Cs7VeLvmWBP1iJHBS48w8FNKhdohRLWF9YGEcQD3CG2xkwepqHanry6epVCPD5SDUQBBejIBkNtHvORdkU4Unl/2Bzvd9IPjfd+Dp7OACEY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790784202; c=relaxed/simple; bh=AOzt/YTI/ILLs9IYpchTVpAiQ7qMhNvW9ATlR/ovttU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XZn/Ks8T7JCufw0JVijVAIXijj2Mb8T9oyGuuC9ngYafrZKhceI+aNzu3YES1DpTLr55T4JiTjq/jwur6eRpCLNKJvV4s/gcF5dfJfee06E6BhBb2N+4pjIoTpqZ85XPHIyjXOSSKuXQhSyWMOH2SITwnjsZhOv5N7gQ7qrS8Fk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=k+U7bur2; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=x1/2Wi79; arc=none smtp.client-ip=103.168.172.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="k+U7bur2"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="x1/2Wi79" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.phl.internal (Postfix) with ESMTP id CE2E9EC02CC; Wed, 30 Sep 2026 12:03:16 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Wed, 30 Sep 2026 12:03:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; 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=fm1; t=1790784196; x=1790870596; bh=4E/P37Rsoc FDWxX34te9BUVPwvpfU+eF7nu4NXtqlPs=; b=k+U7bur2Aldusf7t63P7LekUWc gqPOrhMTHfMGlIv8ncHl+tDFbRyFzMZDmywXgEAawSkxbAvcgEPcdcgz0KGfJIEB vk2ohsvaNFd2CO1XrF9pG0ZvIeadaG1KR73RZHZyfiroKJ5ZoR30GBi0JDRcKPuq JuvSyP7v2EVttMR6eJS1EGc/rthONW4OfgdSEgtCQNbd97BwYCBl95gKVlaOL7oI gIbyPupvb65Cq+da6zQP4XgWukDRhB2yS+TqeN5cJVWw8pO3qs/SvaBcLn+N7rh9 jk/zWw0fjwwPcUOm/YAjnOUApVixK9WssQq80e1gL1qPHz9P1IQp0C+dlQcw== 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=fm1; t= 1790784196; x=1790870596; bh=4E/P37RsocFDWxX34te9BUVPwvpfU+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CpEBYoBDv83qIR5g X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 30 Sep 2026 12:03:16 -0400 (EDT) Received: by mail (OpenSMTPD) with ESMTPSA id f1184630 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 30 Sep 2026 16:03:15 +0000 (UTC) Date: Wed, 30 Sep 2026 18:03:12 +0200 From: Patrick Steinhardt To: Kaartic Sivaraam Cc: Git mailing list , Junio C Hamano Subject: Re: [RFC PATCH v2 4/4] setup: communicate why a directory is not a valid git directory Message-ID: References: <20260924120502.2642141-1-kaartic.sivaraam@gmail.com> <20260929102513.712181-1-kaartic.sivaraam@gmail.com> <20260929102513.712181-5-kaartic.sivaraam@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260929102513.712181-5-kaartic.sivaraam@gmail.com> On Tue, Sep 29, 2026 at 03:55:10PM +0530, Kaartic Sivaraam wrote: > At the moment, there are a few scenarios in which the error message > surrounding an invalid Git repository is a bit blunt: > > $ GIT_OBJECT_DIRECTORY=/does/not/exist git --git-dir repo.git rev-parse --is-bare-repository > fatal: not a git repository: 'repo.git' > > In this case, even though repo.git is a valid Git repository, > we get an output saying it is not since the GIT_OBJECT_DIRECTORY > does not point to a valid object directory. At the moment, the > user is on their own in figuring this out. > > Instead, make it more easy for users to figure such issues s/more easy/easier/ > particularly in cases where they have explicitly specified > a Git directory. This intends to improve the error reporting UX > by clarifying why the specified repository is not considered valid. Which I think is a good motivation. > We achieve this by means of using the new helper > is_git_directory_verbose() that has been introduced. With the > same, we get a more helpful error message as follows: > > $ GIT_OBJECT_DIRECTORY=/does/not/exist git --git-dir repo.git rev-parse --is-bare-repository > fatal: not a git repository: 'repo.git' > reason: cannot access object directory '/does/not/exist' set via $GIT_OBJECT_DIRECTORY Having a separate "reason:" line feels a bit off to me, but that may be subjective. I'd have preferred to have it on the same line, or maybe first have "error:" followed by "fatal:". > diff --git a/setup.c b/setup.c > index a0fb68f7f6..a0d3c0c5bb 100644 > --- a/setup.c > +++ b/setup.c > @@ -1195,6 +1195,7 @@ static void repo_discover_explicit_gitdir(struct repo_discovery *discovery, > int *nongit_ok) > { > const char *work_tree_env = getenv(GIT_WORK_TREE_ENVIRONMENT); > + struct strbuf invalid_gitdir_reason = STRBUF_INIT; Nit, please feel free to ignore: I'd just have called this `errbuf`. Patrick