🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #3386

Re: [PATCH 3/3] submodule: accept a linked worktree as the submodule's git dir

#3386
From: Adrian Ratiu
Date: Thu, 19 Nov 2026 12:19
61 lines
11707 bytes
On Wed, 18 Nov 2026, Junio C Hamano <gitster@pobox.com> wrote:
>> @@ -2191,7 +2232,13 @@ int submodule_move_head(const char *path, const char *super_prefix,
>>  			submodule_reset_index(path, super_prefix);
>>  		}
>>  
>> -		if (old_head && (flags & SUBMODULE_MOVE_HEAD_FORCE)) {
>> +		/*
>> +		 * Do not reconnect a linked worktree to the submodule's
>> +		 * main git dir: that would take over the git dir of another
>> +		 * working tree.
>> +		 */
>> +		if (old_head && (flags & SUBMODULE_MOVE_HEAD_FORCE) &&
>> +		    !is_worktree) {
>
> If a linked-worktree submodule 'sub' contains a nested submodule
> 'inner' whose .git is a directory, submodule_uses_gitfile("sub")
> would have returned 0 (because the check is recursive), we ran
> absorb_git_dir_into_superproject() (which is also recursive so it
> would cause .git in 'inner' to be absorbed), and is_worktree is
> still 0 at this point, which means if() condition here is satisfied
> (if forced) and we will enter this block.  Would it cause an issue?

Yes, good catch. I reproduced it with a "sub" linked worktree and a
"sub/inner/.git" directory, a recursive checkout absorbs the "inner"
and then rewrites sub/.git to point to "$GIT_DIR/modules/sub" which
does not exist:

  fatal: gitfile does not point to a valid repository: .git
  error: Submodule 'sub' could not be updated.

It's basically the same breakage this patch is meant to fix, just
reached through the absorb path.

>
> I am wondering if the check for is_worktree should be moved outside
> the else clause, i.e. making the overall flow look more like
>
>         if (old_head) {
>                 if (!submodule_uses_gitfile(path))
>                         absorb_git_dir_into_superproject(path, super_prefix);
>
>                 /*
>                  * Now path/.git is guaranteed to be a gitfile; 
>                  * validate and detect worktrees.
>                  */
>                 ...
>                 is_worktree = validate_submodule_gitfile_dir(git_dir, sub->name);
>                 ...
>         }

Yes, that fixes it, the sub/.git is left alone and the submodule is
checked-out at the correct commit. The validation also runs after an
absorb, but absorb puts the gitdir where submodule_name_to_gitdir()
says it should be, so the check always passes.

> Or am I grossly misreading the code flow?

You understood it perfectly. :) I'll do this in v2 as well.

Many thanks!
Technical Details
Message-ID: <87y0aphv3v.fsf@collabora.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-75829-linux-kernel-git=dewy.ru
References: <avuJBGlB3pRU3JU0@pampelmuse> <20261118163249.1693361-1-adrian.ratiu@collabora.com> <20261118163249.1693361-4-adrian.ratiu@collabora.com> <xmqqv75t534o.fsf@gitster.g>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-75829-linux-kernel-git=dewy.ru
From: adrian.ratiu@collabora.com (Adrian Ratiu)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH 3/3] submodule: accept a linked worktree as the
 submodule's git dir
Date: Thu, 19 Nov 2026 14:19:16 +0200
Organization: Usenet Network
Message-ID: <87y0aphv3v.fsf@collabora.com>
References: <avuJBGlB3pRU3JU0@pampelmuse>
 <20261118163249.1693361-1-adrian.ratiu@collabora.com>
 <20261118163249.1693361-4-adrian.ratiu@collabora.com>
 <xmqqv75t534o.fsf@gitster.g>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: usenet.network;
	logging-data="2868230"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Yape44jsHLJvPWMb0nkfsOkUc3I= sha256:2X/GHFycqqqHfjxtTB2j4H8YCX3ITjIzbe5k3dLOrQQ=
	sha1:3LWd3iSO+bktEJenYcRkh8+t1K0= sha256:4HGHZ76Q2vi8hGYMiCMlT1bH3KJxIval55grT8b4wX4=
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 EE73111561D; Thu, 19 Nov 2026 15:19:53 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.85
X-Spam-Status: No, score=-2.85 tagged_above=-9999 required=6.31
	tests=[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 ymAvVbLjc0Fb;
	Thu, 19 Nov 2026 15:19:50 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=git+bounces-75829-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 8539B115609; Thu, 19 Nov 2026 15:19:41 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 32B7261EEEA; Thu, 19 Nov 2026 12:19:40 +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=1795090779;
	b=yd/Z41UAsS9lQno/iAazBw9mhOPLcKzxllco5y1W+xiS78DLcw+PdUW20ihs98+mWUr1
	 +AWhsubiA50Zw3/GOJ71Buqm+mtuHjQrn4BpQEKlBXt+HTDelAqc6g8JQzRXkuGHVr6y7
	 fNTI9E9M7+hZBzIfq0MFAZF32RA4cyfowmCI7IWnX6Tv+LOi1R9D5ucArx4aAR1iA7UAY
	 ZS2p8ISuOEE3J80+BgauxQq38wG78Wb/eJFMum+K1tMZgSaSpuUU5lvgMeb15Bp2a6thL
	 wDBKL4PayV80ZoTVuDP0HYBscNPdc4FjfxeLj4LYCF8iZQ7usa1x46kaYB8RxbkH5UA==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795090779;
	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=9lI+sXnNdiG+I1Lg2bK6OK4M1Y4rN5HBGA/El3cqc3U=;
	b=pVdSvTX+2GQzAOeaI20bkBZom1fcrFvo+UfEhK3FK72yYcXkKV60QmM22U9qJRJcUiGG
	 a0OZ/+kD6fnhbpJM8MNBHhEGERzvf0sXFHtV1LY8qQoCda+bb/ZLTTqbw5BgNJWl7N1QU
	 DamMdvQZ36jBWkeDBWzecP2mnwoimijK1veHB/dm8gWFDbOomJU0SLAaXf7vxOkwynQK+
	 1Reb20uJniQ7F8O8w9sbE01/gL3nhulGG26f1EolGeNU6+KYmUw8nQKU0Tb1fz75Rg/i2
	 Dcy6bhmd2OJMRtyF5/x+PCP+OaFosP+lLiSbnDhel8pVm8B/z1bopxfibvmL1SrsrSA==
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="dp/kLZBV";
	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 04434606A330;
	Thu, 19 Nov 2026 12:19:39 +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=dp/kLZBV
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=1795090778;
	b=mRxW/WhqCgdBoeJZJdnnNJN6U1czekkr+Ug/eomtd2an/WLFN1Ij7Ch9flJxJulDuWw5
	 P9LGh1MbfcXhvFL7aLE87G+ppDrOGGY1E1aA4W6W1584ZFCsXu3YY+un4WC+CttdYLfHX
	 advwnByRvuw1b0eujE68aAvRMyjIFDwaH8vfRJfLaAq33IB1updn6b97E4bScFYJotFL1
	 pdMgEtX29eCMzMQQb42C3XQZMqJoc741W9OEtdSN66mfFyz4z1P53Q7krt20lkqv1w7Gl
	 VsFoRjFrojUY239r9l0uzTliIi8+m4ld7X5Q/5mlqB160MY7BWFC0hSp7jHhbbgC2Gg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795090778;
	h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:In-Reply-To:
	 References:Date:Message-ID:MIME-Version:Content-Type;
	bh=9lI+sXnNdiG+I1Lg2bK6OK4M1Y4rN5HBGA/El3cqc3U=;
	b=F0bWy1GfU/9vR8KVZWbVvYbUkC3CsAY5RHE3GJh2Zfd9obPp76+1jhgQDIVCYxlCjdPB
	 RnhCVmbr9+hPm7EuaCoy1A2rj9I8dl/g8+rnm8HhGEQgHgKFz+51d2u8p/+zSvHugvzqF
	 J6ESRZGb1fc8QH6p2ENLal3XJgH2YWREPMxxT6HAteymXe9dZw1a9cONMUvInNjdN/HHd
	 Gu2dZT5ad8tZgx4QRkv3+nEcU/Kegn2hyBopBfOJyLykK4Za3Z94bm7O1rxQrYWGkUWX4
	 2m8gIgwhnMKmhTKXNchI6VaNLnDHZvNUWLUWKExp6uycE1QsdM4MspR06J7P1KLKIdw==
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="dp/kLZBV";
	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 9ED46606A320
	for <git@vger.kernel.org>; Thu, 19 Nov 2026 12:19:37 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9ED46606A320
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=1795090763; cv=none; 
	d=zohomail.com; s=zohoarc; 
	b=eOzyVuCjnXEeN0eRm8c76JLOO2PKnYFb7hUbftmddpl2nrW6aDmMTJH46cpG0za2abIdxDoyDkcE1+18fk7LJTcFJuymV8N9F2lEkGMKpbK+sMobLXSEMQVAN7k4gIMEPc8DtkKGZUzaGpbQQ2MmZGLjRmN56sOlOrPPSUTsDNI=
X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; 
	t=1795090763; 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=9lI+sXnNdiG+I1Lg2bK6OK4M1Y4rN5HBGA/El3cqc3U=; 
	b=ADVwnhU0T/gl4FMrNyrFJl62QnstZVYp9v+j4sB0GRRmbLiQQ6TIvXu4xcPpQ36pwJalPj/AG1WNtHsxbcqadxvSySqbQcuPZ2COUhe9VGk7vjBJ+n5hXQviqP4GQ+8NEZdjpciIph3YE43qUusRBQdH7ZNLju72VoSVI6Hed40=
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=dp/kLZBVjJcoH8X+Rf3ZWJL3KiHpauZw1XcixE7tsyLhUZxG0mcX+mc+ix0gwImPSgJ9n6SqypSNGTFOkd99L2ReE/3ASngcn3nouGHT2VPkgDoozoLD29hSwZTfRiCz0dw63GZkLMtp4g7PzjvQDE0q/+ozAJODModksDet0/8=; c=relaxed/relaxed; s=zohomail; d=collabora.com; v=1; bh=9lI+sXnNdiG+I1Lg2bK6OK4M1Y4rN5HBGA/El3cqc3U=; 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 179509076145181.70465685333068;
	Thu, 19 Nov 2026 04:19:21 -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: <xmqqv75t534o.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