Article View: linux.kernel.git
Article #3327Re: [PATCH 1/3] submodule: return an error instead of BUG() for an unexpected git dir
From: Adrian Ratiu
Date: Wed, 18 Nov 2026 19:33
Date: Wed, 18 Nov 2026 19:33
55 lines
11424 bytes
11424 bytes
On Wed, 18 Nov 2026, Junio C Hamano <gitster@pobox.com> wrote:
> Adrian Ratiu <adrian.ratiu@collabora.com> writes:
>
>> 9cf8547320 (clone: prevent clashing git dirs when cloning submodule in
>> parallel, 2024-01-28) added a caller that passes a path read from the
>> gitfile, which made the BUG() reachable.
>>
>> Return an error instead of BUG(), so the command dies with the same
>> "refusing to create/use ..." message as when the submodulePathConfig
>> extension is enabled.
>
> Makes sense.
>
> The above archaeology was quite illuminating. It seems that the
> offending commit came without the usual on-list reviews as part of
> the Git 2.39.4/2.45.1 updates.
Yeah, I wasn't part of discussions on this, so I don't have the full
context either, but I do think switching BUG() -> error() makes sense.
>> Reported-by: Andreas Wendleder <gonsolo@gmail.com>
>> Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
>> ---
>> submodule.c | 8 ++++++--
>> t/t7450-bad-git-dotfiles.sh | 14 ++++++++++++++
>> 2 files changed, 20 insertions(+), 2 deletions(-)
>>
>> diff --git a/submodule.c b/submodule.c
>> index 1302c11ddf..d00d820d42 100644
>> --- a/submodule.c
>> +++ b/submodule.c
>> @@ -2410,10 +2410,14 @@ static int validate_submodule_legacy_git_dir(char *git_dir, const char *submodul
>> BUG("validate_submodule_git_dir() must be called with "
>> "extensions.submodulePathConfig disabled.");
>>
>> + /*
>> + * The git dir may come from a gitfile on disk, so a mismatch is
>> + * not necessarily a bug in the caller.
>> + */
>
> "is not necessarily a bug" is not incorrect per se, but it is only
> relevant in the context of turning what was originally a BUG() into
> a "return error()". If this had been written to return an error
> instead of calling BUG() from the beginning, you would not have
> phrased the comment that way.
>
> If this if() statement needs a comment, we should state why these
> two are expected to match, or why it is an error if they do not
> match.
Good point.
I'll drop the comment addition in v2 since we don't need to over-explain
the BUG() -> error() transition.
Technical Details
Message-ID:
<874idej5o8.fsf@collabora.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-75734-linux-kernel-git=dewy.ruReferences:
<avuJBGlB3pRU3JU0@pampelmuse> <20261118163249.1693361-1-adrian.ratiu@collabora.com> <20261118163249.1693361-2-adrian.ratiu@collabora.com> <xmqqecci54tw.fsf@gitster.g>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-75734-linux-kernel-git=dewy.ru From: adrian.ratiu@collabora.com (Adrian Ratiu) Newsgroups: linux.kernel.git Subject: Re: [PATCH 1/3] submodule: return an error instead of BUG() for an unexpected git dir Date: Wed, 18 Nov 2026 21:33:27 +0200 Organization: Usenet Network Message-ID: <874idej5o8.fsf@collabora.com> References: <avuJBGlB3pRU3JU0@pampelmuse> <20261118163249.1693361-1-adrian.ratiu@collabora.com> <20261118163249.1693361-2-adrian.ratiu@collabora.com> <xmqqecci54tw.fsf@gitster.g> MIME-Version: 1.0 Content-Type: text/plain Injection-Info: usenet.network; logging-data="2684089"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:m+puPOVwleWAF/TYGkZmzhRMjuw= sha256:0UZZ6FDI9I0KMeDVmGMdq/wt0b2IlQb/boNNpOgpEp4= sha1:uqdV+c95tZwfStD7NZN5HpQFcbs= sha256:xOeAq6KJC/nxAUmZAOOGTQBQumpCpgK8IikWfhAhFiU= List-ID: <git.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 19E2D1153B0; Wed, 18 Nov 2026 22:43:07 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.75 X-Spam-Status: No, score=-2.75 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=collabora.com X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DKfFBFTudhoR; Wed, 18 Nov 2026 22:43:04 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=git+bounces-75734-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=collabora.com X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 59EB6115387; Wed, 18 Nov 2026 22:42:54 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id A5681161B97; Wed, 18 Nov 2026 19:38:36 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795030430; b=ILJdMehc+bfgOe1NS4seJONAikZro5pVu8DfSbXgpP8LvcBrf/6Fc5Ky3c+ypYC5RN/i 50bP3R6D+5KenUSpxg9fSWYyur7SM5j8QTkgS630Y50u+R52G/A+NA0JsASlG8ulS0WK2 +e8uxQCXTOdUFUxin/IfFCIAeSP/ojB96tvcg7d0MUvDwMuKmnnbCl1LL8WxyunT08sML fNDlSd0/zJtNMRBjQalYb8irS4ye2g6Ux2MvHF8a8BJUBJ+U517b3cRt2QYZodqvepG4i k9p6QVU39JFG0boL7zLb8iMfKfItcFKZV1/S8zuuVxACjNKFwTzaFNwN3j7zXToSOLQ== X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795030430; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To: Cc:Subject:In-Reply-To:References:Date:Message-ID:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version:Content-Type; bh=bobzesAlZx+G2IcjZ+oR/JrlT/FIVHHDu2foaEk3mDQ=; b=WWuN9jIEsnKluAbIQup36Nm+GnCc1xNM4KlS7a+pEXGz4HSE6uXQ+zvA8tXz1wjf3IyQ 7eQIabThCfl240z725ahXwLlD5OJ6KLmsCPKI8WPdZlcwz47B2NzF6VX9jlnPyPgNl9Lh dMm1ULQBKC4/scJdsEZ7QJrEftD7LPuzYQDgLjwh+6fUhV/otnKpUGY9os0NjAx1UzTYh zsE4OSLf3i3/YcEy7klFp8SbdRCrRuM6/l8eAWXN6RLSNNkc6XEs6y4TpGb2rN6IXk6DW rB2uEhWWNITPu0tdouBJY4fvT0DzNDKOVt4E+wTu0CcMBKfgn7q2rrs03UuczTLELLQ== X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=zohomail header.b=Vl5u79G6; dmarc=pass header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AC21E606B41D; Wed, 18 Nov 2026 19:33:50 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=zohomail header.b=Vl5u79G6 X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.182.12 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795030429; b=HvGylcxMQudx+RVQWYVx/XVqp6sO95QY6j6M4lIqzQZy54By64bKWHLOLmSkocz5bxn9 l97NXxAIEaBMpg03IDu5o1XAk49t2Huyu85Gcjqv3nzHFfMTu7N2TuRiO5VMAVePCytqr s3e6qFgatped3cu8F59a0pTu014LQekrTeztCVI0BeFqkr6Gn5UfG2SCH7sYFX+nVi9bf CFrKCO0ln/ugzvVpZhhWkAnD/Z5c3UrOnjQPMiB1tdsJnvVzxGi+PTgNPUZdCwojN78bj VmtuSMOoOc2KYU28WAJct/kidkLRVJrEaD6p8xz5GpsJ+7ofRxtACsQjOaR9rRRDx5g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795030429; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:In-Reply-To: References:Date:Message-ID:MIME-Version:Content-Type; bh=bobzesAlZx+G2IcjZ+oR/JrlT/FIVHHDu2foaEk3mDQ=; b=ipfQOEc91fqjPccNIgwPlgrmXM8XNW/ZqvRvcNgPhCwT3Zt53q0M//nHXICVV+aLQNzS oyVfmWw7gxkqrt6Rn5w6sT2RsYXzZmj+o1rXM10xh5GKt0gYZ7Sco52wliOZbCDFJC5yT GoFBgn3Xivuk91ugqoIbbASuBpQww+hSTgWyQBS1yfSCDMZFWgZBBUR0z7jkFOPotLllD f03IHzTvgLrURNKYMl4lQK0S5IEO5znsOImgn2kYOZ8+xYtjo13xgsEUKlls8mLvu1x81 9EXIM7rYN1EAdAdY0eS/a7Cu0P7hPnfj8ut2fHxufftLJUu6qHEwQPAXYzWwzFA6ggg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=zohomail header.b=Vl5u79G6; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.182.12 X-Received: from sender5-op-o12.zoho.com (sender5-op-o12.zoho.com [165.173.182.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60D6C606B411 for <git@vger.kernel.org>; Wed, 18 Nov 2026 19:33:49 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 60D6C606B411 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com X-ARC-Seal: i=1; a=rsa-sha256; t=1795030415; cv=none; d=zohomail.com; s=zohoarc; b=ROLt7USlZnP9AH+0EiRhLDOUG7wKg0Q3+ms8deQtFUCLwnwHfqrqVqtWqYuQL5vI8FB8x6WuIfZt3EUXItgeaOWMJVDEIvZnm0azNS4j9RB0jXpC7jszIs+RLQfiYbPyw+M+W0k22HHbIq9BuUM2VSul7VQJxwAkOkN7istMt5w= X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795030415; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=bobzesAlZx+G2IcjZ+oR/JrlT/FIVHHDu2foaEk3mDQ=; b=oH2D9WsbM6UyGsT4pUEi0fWAj4NRDMEZiWSkeWeyUnl/a/gACdgOANKeykVV7xJC+LDK5+yQ+2D9cvFhaynxWPdeRxE68HE2HDIwPTWqr+Yw2Pewp3TRzrPQ66J8guOhuyszcyKb6mjL73V0njV4eX9XsIOGLYmzT96QtAOQ3xQ= X-ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=adrian.ratiu@collabora.com; dmarc=pass header.from=<adrian.ratiu@collabora.com> X-DKIM-Signature: a=rsa-sha256; b=Vl5u79G6yfofM5iKqn2MtkMMrpigMgJjWkpoCgQTyRaGyf/G0MW1PwJBaqfQjeI/k7hIwAobFt43OSK4kzA2vCPWVY04y9ip5EnVtVDygr1RXGDG0kD/bA3BbXZxIyCltLOWDILq6eNgAap4p+3+aUXC/V5+mHGtfOLpkG3TM9I=; c=relaxed/relaxed; s=zohomail; d=collabora.com; v=1; bh=bobzesAlZx+G2IcjZ+oR/JrlT/FIVHHDu2foaEk3mDQ=; h=Content-Description:Content-ID:Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Resent-Sender:Resent-Cc:Resent-Date:Resent-To:Reply-To:Resent-Message-ID:Resent-From:Sender:Subject:To:Date:From:Message-Id:Reply-To:Subject:To:Cc; X-Received: by smtp.zohomail.com with SMTPS id 1795030413964194.5349348168229; Wed, 18 Nov 2026 11:33:33 -0800 (PST) X-Cc: git@vger.kernel.org, Andreas Wendleder <gonsolo@gmail.com>, Phillip Wood <phillip.wood@dunelm.org.uk>, Patrick Steinhardt <ps@pks.im> X-In-Reply-To: <xmqqecci54tw.fsf@gitster.g> X-Mailing-List: git@vger.kernel.org X-List-Post: <mailto:git@vger.kernel.org> X-List-Help: <mailto:git+help@vger.kernel.org> X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:git+owner@vger.kernel.org> X-Precedence: list