From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796245615; b=bxXP9Es/jl6U6316aoOr9O8Yccu0Mf99lD1iEHG3zCrGqmMdT+yMjVQQ1GPTB8JtELOM KKZZVq6Bgpt6NGGFVDL0qG4pMkwbXCGh7Xqibz2utk9KhFKxGPsN8KeqHhqJS7kw83Wbb KUJmCoZsSgMPTQkp94yztxRbig0e1c/jjqAhKA7EYPr5B+15ofaYusrEFC3R6frrppzc0 Zv7UfD5scSZGRLUj0urR6cvsu2Z746sXpmXfzlKZZfFG+G0H723l/2YoDUKDh53OKqvVT VbUdDGWzOlLA3L7pFa6WmXiCPn9WTxLvtLrI0jtl70V7lqMeJ9dO15xS6vP3HIW66CQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796245615; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Message-Id:In-Reply-To: References:From:Date:Subject:Fcc:Content-Type: Content-Transfer-Encoding:MIME-Version:To:Cc; bh=9Y5rfqWDLQhtsr26x8Ci7aeNoV/umfnVzeaO2xG95y0=; b=baU4WikTxF5gnwjjwKrwvTv4LbKVDtv76oFM2rDmNnng3OnGHHdm/VI73D7205vagumC bJkFMJiU284+p8d95j1d8m5tFTUuIpFnMyhCSc8TWkasQqkMGIoi1ZkWsFCuTYYqn8wCN cqXQkeOI9PFkx7MTzuxxA7pCXgT5UX96T6FaiwcsFs8rdXsGDZvNm5tWLfkQnAERAJ274 sxvATNk2X4LmccFF/p+1aVkxwYb3x/K7aZ5C0Ea0JHy1cxIKv2VXd3qH6nob2q6J9iRBo VDLDbLokxWVSeEHxttrQ6OfPNYGKosXv+10+WUGglhsMpjLDDNX5knZtFfQMBimCCzA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ypktScsa; arc=none smtp.remote-ip=74.125.82.46 Received: from mail-dl1-f46.google.com (mail-dl1-f46.google.com [74.125.82.46]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19F1F606A32D for ; Wed, 2 Dec 2026 21:06:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 19F1F606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ypktScsa Received: by mail-dl1-f46.google.com with SMTP id a92af1059eb24-1b59dfe466bso7200428c88.1 for ; Wed, 02 Dec 2026 13:06:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796245614; x=1796850414; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:content-type:fcc :subject:date:from:references:in-reply-to:message-id:from:to:cc :subject:date:message-id:reply-to:content-type; bh=9Y5rfqWDLQhtsr26x8Ci7aeNoV/umfnVzeaO2xG95y0=; b=ypktScsaf16pH3ky/gF+lSZSFPtMrf1pRYnr+5bsvZBrAaNz6FbzYaT2IGczE/zO13 WImo1pAgD/5Tpq7DXt5K6d0juG6qFIxgCqmMoESJpBga+VqcbRpH5BjLQMkQYrQXyNn6 CdcyW3zBPcPNtQhSuEJtMu2PicfCQu3mLL90ljvh+0jn7wsJGqdul4na1ewIpOGnagVC IgJ66oe8U7tkkDBu4K0qNu96of8pr6Gd5Yg8iFmPsbKXBZBYxl7I8gAkQE51I2CKhAM9 36sXH//WzEnHr1Hwiz5iuXmOuT4xcc+Ija/mjEj7OILQZaRVwvDEMj5GMzezmdz0xwFB oI3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796245614; x=1796850414; h=cc:to:mime-version:content-transfer-encoding:content-type:fcc :subject:date:from:references:in-reply-to:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=9Y5rfqWDLQhtsr26x8Ci7aeNoV/umfnVzeaO2xG95y0=; b=2ubIpjhTxFGmfEV0BKAEQqRmubJ+ZPnBtT4I3LlIkIYkaxYzLhAq1HFbpr7Gaw2UA3 otYwwBKHh7EcII7td7WiYviuEYmNfTHDZ1DVwgbpdNZiPEK7+HLduUcJeCWk07h3fFSU rztFWTAYZgGTufJKJ0PQPA1yPggnCR0OLOg3VeA17RAckI8hUGl4ei5ma2fd0c+Qa16I T0XGEItUTNyDS7+XSon0RiMIAgN1LD2IBODrsOQE/w5rdx3gWydJJZ9xOrw+NioJVvjP 8kf94QUb+bUgOYZK/krqiy/CZegm+qiHcofSm6MFamgKw2YTBoRBESWOSwRR/Cd2qIS+ rP2w== X-Gm-Message-State: APuU4Z8oOX0zxcIc0W8tNfZecJwTLVPMC6HuSAW9IOTzzXcyduP6pauP +gMBe+EJMcCR6y3QvGqOqByhvNEncw6eHXRMnEKQ4ebH42/Qy5a6MCs3KqAhdw== X-Gm-Gg: AZFdTZdc9hUlnx8K1BUdQmWzK2bY2ZIaVqyOjCh/zx/wIAU27GMWqIufr81Jp1NtEXK sr51WUqNEZt2O6rt9Rk/Cp1m8ho/+OOA2p0JR1MfhcqtoTrVCup94yf9DKmZ4TRM8p9n0J6XyAx R201fx2pV/pA2/H4bTutpucE/fGN2t0AidLzouUYPQGQGJof17dVEC7r5ONQofajwdJZxVMNcnU ruBOhSgAwv6QWIiikXkO4yHYdIPZx56knQc1jRj+02DK3iS4Y6FLUzxu4I0vNTKd+cbrIsmMGhy scacy33FjaU3LUWpbjtCgOnDzJoZzCrqDkO2nA09+knC3AcheYVqlzQzGpqbjM5S2Eqg6UuHYY2 ygtblWe3wjW+TfQ42W2Nb9AMbbsKE+vb/62w3o/d1pJHDan/zcrVeuLRGq1S4u8z2YkMVMHtSn6 R1QMMz6q4z8ZZPuoSwHf+8mHyij9HsZq7YSYdzFN19K4CmN9EUFpWAaVjRZWJLKTzobJHxUhS5/ J0/aPk3lrm1UoO4wJBF/mLKU19i5QFUSQ2ye0tjWDDgylnrCsqVUss9O3Yqd5GmQxbAZHD7yLae lXwzJvCRNI66xj7lwCLnQT03PtrZBCU= X-Received: by 2002:a05:701a:ccca:20b0:1b5:71bb:6800 with SMTP id a92af1059eb24-1b571bb698bmr29945497c88.3.1796245613954; Wed, 02 Dec 2026 13:06:53 -0800 (PST) Received: from [127.0.0.1] ([20.171.22.246]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b55682d301sm98497477c88.10.2026.12.02.13.06.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 13:06:53 -0800 (PST) Message-Id: In-Reply-To: References: From: "Yoichi NAKAYAMA via GitGitGadget" Date: Wed, 02 Dec 2026 21:06:48 +0000 Subject: [PATCH v4 0/4] submodule: support worktree-specific configuration Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 To: git@vger.kernel.org Cc: Yoichi NAKAYAMA , Yoichi NAKAYAMA When using multiple worktrees, submodule settings stored in the repository config are shared between all worktrees, even when they need to differ. For example, different branches may use different URLs for the same submodule. More importantly, sharing submodule..gitdir causes submodule worktrees to share the same HEAD and index, even when the corresponding superproject worktrees record different commits for the submodule. This series makes submodule settings worktree-specific when extensions.worktreeConfig is enabled. It also keeps submodule..gitdir relative for linked worktrees, so it continues to work when the worktree is moved along with the main worktree. Included commits: * [1/4] Keep submodule..gitdir relative for linked worktrees. * [2/4] Resolve symlinks in submodule..gitdir. * [3/4] Store submodule settings in the worktree config when extensions.worktreeConfig is enabled. * [4/4] Make git submodule init copy an existing gitdir setting to the current worktree config only when it belongs to that worktree. Changes in v4 ============= * [4/4] Resolve symlinks in submodule..gitdir value * [4/4] Fix the warning message Changes in v3 ============= * [1/4] Copy the path early, as relative_path may continue to use the provided buffer * [2/4] Add new commit to resolve symlinks in submodule..gitdir value * [3/4] Handle duplicate submodule..gitdir on 'git worktree add' * [3/4] Add more explanations * [4/4] Resolve symlinks in submodule_git_dir_matches_current_worktree() Changes in v2 ============= * Update the cover letter to better explain the problems this series addresses. * [1/3] Copy the string returned by worktree_git_path() early. * [2/3] Expand the explanation in the commit message for why the gitdir config is excluded from worktree add. * [3/3] Explain the case where the repository config contains a gitdir setting for another worktree, and warn when the setting is not copied. Included commits: * [1/3] Keep submodule..gitdir relative for linked worktrees. * [2/3] Store submodule settings in the worktree config when extensions.worktreeConfig is enabled. * [3/3] Make git submodule init copy an existing gitdir setting to the current worktree config only when it belongs to that worktree. Yoichi NAKAYAMA (4): submodule init: make submodule..gitdir relative for worktrees submodule init: resolve symlinks in submodule..gitdir submodule: store settings in worktree config when enabled submodule init: copy submodule..gitdir to config.worktree Documentation/config/extensions.adoc | 9 + Documentation/config/submodule.adoc | 14 +- Documentation/gitsubmodules.adoc | 26 ++- builtin/submodule--helper.c | 211 ++++++++++++++++----- builtin/worktree.c | 23 +++ t/t2405-worktree-submodule.sh | 157 +++++++++++++++ t/t7425-submodule-gitdir-path-extension.sh | 180 +++++++++++++++++- 7 files changed, 563 insertions(+), 57 deletions(-) base-commit: acba8bf9753134d9bde89f94369f775838a8c5fe Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2306%2Fyoichi%2Fsubmodule-with-worktree-v4 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2306/yoichi/submodule-with-worktree-v4 Pull-Request: https://github.com/gitgitgadget/git/pull/2306 Range-diff vs v3: 1: 6ed1297d8f = 1: 6ed1297d8f submodule init: make submodule..gitdir relative for worktrees 2: 594eefeceb = 2: 594eefeceb submodule init: resolve symlinks in submodule..gitdir 3: f5d3f71748 = 3: f5d3f71748 submodule: store settings in worktree config when enabled 4: 3e2c161298 ! 4: cfee53fc44 submodule init: copy submodule..gitdir to config.worktree @@ builtin/submodule--helper.c: struct init_cb { + "%s", gitdir)) + return false; + -+ if (strbuf_normalize_path(&submodule)) { ++ if (!strbuf_realpath_forgiving(&submodule, submodule.buf, 0)) { + strbuf_release(&submodule); + return false; + } @@ builtin/submodule--helper.c: struct init_cb { + +static const char submodule_mismatch_warning[] = N_( +"config '%s' exists but was not copied to the worktree config because " -+"it does not point to a gitdir for the current worktree. If you want " -+"to keep using this setting, copy it to the worktree config." ++"it does not point to a gitdir for the current worktree." +); + static int validate_and_set_submodule_gitdir(struct strbuf *gitdir_path, @@ builtin/submodule--helper.c: static int validate_and_set_submodule_gitdir(struct + if (!matches || + validate_submodule_git_dir(tmp, submodule_name)) { + if (!matches) -+ warning(submodule_mismatch_warning, key); ++ warning(_(submodule_mismatch_warning), ++ key); + free(tmp); + } else { + value = tmp; @@ t/t7425-submodule-gitdir-path-extension.sh: test_expect_success 'git submodule i + test_cmp expect actual && + git config --worktree submodule.sub2.gitdir >actual && + echo ".git/modules/sub2" >expect && ++ test_cmp expect actual ++ ) ++' ++ ++test_expect_success SYMLINKS 'git submodule init inherits related repository config by resolving symlinks' ' ++ test_when_finished "rm -rf repo-clone-init-symlink" && ++ git clone upstream repo-clone-init-symlink && ++ ( ++ cd repo-clone-init-symlink && ++ git config core.repositoryformatversion 1 && ++ git config extensions.submodulePathConfig true && ++ git submodule init && ++ git config submodule.sub1.gitdir >actual && ++ echo ".git/modules/sub1" >expect && ++ test_cmp expect actual && ++ git config submodule.sub2.gitdir >actual && ++ echo ".git/modules/sub2" >expect && ++ test_cmp expect actual && ++ ++ ln -s ../repo-clone-init-symlink link && ++ git config submodule.sub2.gitdir "$(pwd -P)/link/.git/modules/sub2" && ++ git config extensions.worktreeConfig true && ++ ++ GIT_DIR=link/.git git submodule init sub1 2>err && ++ test_must_be_empty err && ++ git config --worktree submodule.sub1.gitdir >actual && ++ git config --local submodule.sub1.gitdir >expect && ++ test_cmp expect actual && ++ ++ git submodule init sub2 2>err && ++ test_must_be_empty err && ++ git config --worktree submodule.sub2.gitdir >actual && ++ git config --local submodule.sub2.gitdir >expect && test_cmp expect actual ) ' -- gitgitgadget