Article View: linux.kernel.git
Article #4325[PATCH v6 3/4] status: preserve customized submodule remotes
From: "Alessio Attilio via GitGitGadge...
Date: Fri, 04 Dec 2026 12:58
Date: Fri, 04 Dec 2026 12:58
116 lines
14686 bytes
14686 bytes
From: Alessio Attilio <attilio.alessio@protonmail.com>
Users may point a populated submodule remote at a fork. Since git
submodule sync would overwrite custom or multi-URL remotes, suppress
the advice unless the configured remote matches the old or declared URL.
Signed-off-by: Alessio Attilio <attilio.alessio@protonmail.com>
---
wt-status.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 83 insertions(+), 1 deletion(-)
diff --git a/wt-status.c b/wt-status.c
index bbd0e082dc..69c05735ec 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -2696,6 +2696,85 @@ static void wt_porcelain_v2_print(struct wt_status *s)
}
}
+static int submodule_has_custom_remote_url(struct repository *repo,
+ const char *path,
+ const char *declared_url,
+ const char *cached_url)
+{
+ struct repository subrepo = { 0 };
+ const struct string_list *remote_urls = NULL;
+ const char *remote;
+ const char *remote_url;
+ char *key, *up_path, *config_remote_url, *gitmodules_remote_url;
+ char *declared_super_url;
+ char *worktree_path;
+ int error_code, populated, ret = 0;
+
+ worktree_path = repo_worktree_path(repo, "%s", path);
+ if (!worktree_path)
+ return 0;
+ populated = is_submodule_populated_gently(worktree_path, &error_code);
+ free(worktree_path);
+ if (!populated)
+ return 0;
+
+ if (repo_submodule_init(&subrepo, repo, path,
+ null_oid(repo->hash_algo)) < 0) {
+ repo_clear(&subrepo);
+ return 0;
+ }
+
+ declared_super_url = resolve_submodule_url(repo, declared_url, NULL, 1);
+ remote = repo_remote_from_url(&subrepo, declared_super_url);
+ if (!remote)
+ remote = repo_default_remote(&subrepo);
+ free(declared_super_url);
+
+ key = xstrfmt("remote.%s.url", remote);
+ if (!repo_config_get_string_multi(&subrepo, key, &remote_urls) &&
+ remote_urls->nr == 1 &&
+ (remote_url = remote_urls->items[0].string)) {
+ up_path = get_submodule_up_path(path);
+ /*
+ * sync_submodule() stores a relative URL in the superproject's
+ * config without the submodule path prefix, but adds that prefix
+ * when storing the URL in the submodule's remote configuration.
+ */
+ if (url_is_local_not_ssh(cached_url) &&
+ !is_absolute_path(cached_url)) {
+ struct strbuf sb = STRBUF_INIT;
+
+ strbuf_addstr(&sb, up_path);
+ strbuf_addstr(&sb, cached_url);
+ config_remote_url = strbuf_detach(&sb, NULL);
+ } else {
+ config_remote_url = xstrdup(cached_url);
+ }
+ gitmodules_remote_url = resolve_submodule_url(repo, declared_url,
+ up_path, 1);
+ /*
+ * The submodule's remote URL may be a local fork. If it matches
+ * neither the old cached URL nor the new .gitmodules URL, leave it
+ * alone; syncing would overwrite that customization.
+ */
+ ret = strcmp(remote_url, config_remote_url) != 0 &&
+ strcmp(remote_url, gitmodules_remote_url) != 0;
+ free(gitmodules_remote_url);
+ free(config_remote_url);
+ free(up_path);
+ } else {
+ /*
+ * Multiple URLs are a local customization; sync would replace
+ * them all with a single URL.
+ */
+ ret = remote_urls && remote_urls->nr > 1;
+ }
+ free(key);
+ repo_clear(&subrepo);
+
+ return ret;
+}
+
static void wt_status_check_submodule_urls(struct wt_status *s)
{
int i;
@@ -2734,7 +2813,10 @@ static void wt_status_check_submodule_urls(struct wt_status *s)
free(key);
gitmodules_url = resolve_submodule_url(s->repo, sub->url, NULL, 1);
- if (strcmp(config_url, gitmodules_url))
+ if (strcmp(config_url, gitmodules_url) &&
+ !submodule_has_custom_remote_url(s->repo, ce->name,
+ sub->url,
+ config_url))
warning(_("submodule '%s' has a different URL in .git/config "
"than in .gitmodules\n"
" run 'git submodule sync' to update it"), ce->name);
--
gitgitgadget
Technical Details
Message-ID:
<69aed73e2301ea590fff4aa4cbefa4f4d64b1d86.1796389090.git.gitgitgadget@gmail.com>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.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-76993-linux-kernel-git=dewy.ruReferences:
<pull.2509.git.git.1795774880142.gitgitgadget@gmail.com> <pull.2509.v6.git.git.1796389090.gitgitgadget@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.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-76993-linux-kernel-git=dewy.ru
From: gitgitgadget@gmail.com ("Alessio Attilio via GitGitGadget")
Newsgroups: linux.kernel.git
Subject: [PATCH v6 3/4] status: preserve customized submodule remotes
Date: Fri, 04 Dec 2026 12:58:09 +0000
Organization: Usenet Network
Message-ID: <69aed73e2301ea590fff4aa4cbefa4f4d64b1d86.1796389090.git.gitgitgadget@gmail.com>
References: <pull.2509.git.git.1795774880142.gitgitgadget@gmail.com>
<pull.2509.v6.git.git.1796389090.gitgitgadget@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2766673"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:CIJG02Krin0Dz9MVta+LfnSObb4= sha256:EkzRmmJr8PHBmX2sfOuP8SbsYwTgaD1FaOkciq+tBCQ=
sha1:sdv+3jObMHjqTGWKrPH29zasSz8= sha256:7+qfhKh4BKqbTw1tT8ptwzJntQXyo0uStiScc6riwW0=
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 CECD3117BF5; Fri, 4 Dec 2026 15:58:53 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.197
X-Spam-Status: No, score=-2.197 tagged_above=-9999 required=6.31
tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1,
DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.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 QV-5NmY1faDf;
Fri, 4 Dec 2026 15:58:51 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-76993-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 8D9E5117AFF; Fri, 4 Dec 2026 15:58:43 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 895726886B; Fri, 4 Dec 2026 12:58:17 +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=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796389097;
b=gK5zBhTFAz37GDoTV+gN5v+cMyzKns5GtDdRQZF0ESF4BFM0iIEmwcCsgh7ePBjq2y67
HXJTJDqz93djvaV+J2zxQNxiE0+92JmArh9qsx2jJgGAg0Fi4oPHInpnGRNDt2P+RVBqK
zoBRjUcCSXCPU5uJmN+wyzf5Ufc5itkhgo9e+EvSJtq0MDkJC+WS+Gu8PwN9iQaBVxf0s
Te7TWT7VO5/yNj0uOtYBeipa6oe3mSVF17mcy9e2aipvdIp+tUHUuvov5dSWC587UYmND
GvEO7sAd8PAkmFnfcUKn4C9y29M1ulHYRSGWKMBngo8xo6b0z2CrjFvc1NNQkSeMyYQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796389097;
h=X-Original-To:Received: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:X-Mailing-List:List-Id:
List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
Precedence:MIME-Version:To:Cc;
bh=Oa+J//Dv+4Dzdu/avxmTCwmzD3lGICP/yQrhSH28DTM=;
b=1NDbyy1IDAuHfcQGSvhWJr2NCUxG26MPmUP6PnYzQaM3bMzyw28jTujuSuMl601WyKZE
47Y2MikOAbyG2ktjbmqfaxiToQXtCEk5yP2MhfaE9L+1neKkzIm6yV31iGe0XVzgoLD5E
J5sfGNaO9QZpCAm19xripkUBveXFqRWHRBO+J7WDArChMId5ANBQcOhYeZHTh8qwrR7a3
+oFTBr0QCh2xF9gPulbrHC3E/GqPyp18eA7MW4jw5202VE2RaRr4U2WxUYHNJnK4ESDva
ENypSppXj0gx1IK5Zo7TElYj2t9pA8ctpUWJi2QxjYKMvinQ56w5iu6aIuZF8QChjyw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=oqGLwduM;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.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 5AD5C606A33B;
Fri, 4 Dec 2026 12:58:17 +0000 (UTC)
X-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=oqGLwduM
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.43
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796389096;
b=v0OwHi7sTgXuEitXwFP3cH15dPsSAuhY7KN9uHsf9C8gTbeQlx2o5tMlLmw4100C4CBI
Xfq+tDtJ5e/Q9KKcZaPfD8k1B+h5l49YOLGKr8NzxiktsKC+l1d3lcnVFPgESws6soMI+
AbNJbXkT+l2H2FsRJgEGBRA8HLhJ0TOUnx9INh5TY6Sdb7CUOPAi6JE/6rNHRE+Cfeely
eJubJWkWK3K/2GVCksBHDAC3OOjD9HJTeDhNvvVUNiAhDpCw/gMZTqfKPby7mL5ccQk4h
AlMIY3q/NDfg0K9bA71U4fyzotPfidgZHOO6205qQF1QOfxfA6dRcIoP+d54EUK9NUg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796389096;
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=Oa+J//Dv+4Dzdu/avxmTCwmzD3lGICP/yQrhSH28DTM=;
b=irgB0qsPg1Jz4B8rvQ4Ovk5sNvpbxKJiGd2wK2rwr3a2QwvOHNgV0frcyyhLQ/gWE2iY
tVufb4O8F24riIXE1JUgGKzoHjVb7GHw/vtg41eomStpqPdct4m6n7XmBmV2K1u6dK8Al
cHjhCrhctKbytqmAhPm1UxCLhBRcnS+gDNlctSo4RHpzKbE0GxJ2PC2fjUe6q2v4sSUW6
AI744HIoDU3857q/QDJbEAqo1V4EGra52aklauxUQmHspDU9HmSJTZvoPTcwHOfNsJWQj
Q5YOhzlNKQLgTxNcWhhtbvVRT5ZcSxtVUbKPSlBomLkNQeThjNlIoWUL3WQFAzzDkLA==
X-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=oqGLwduM;
arc=none smtp.remote-ip=209.85.216.43
X-Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43])
(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 33DA4606A684
for <git@vger.kernel.org>; Fri, 4 Dec 2026 12:58:16 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 33DA4606A684
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-3b542b4d7bcso447226a91.0
for <git@vger.kernel.org>; Fri, 04 Dec 2026 04:58:16 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796389095; x=1796993895; 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=Oa+J//Dv+4Dzdu/avxmTCwmzD3lGICP/yQrhSH28DTM=;
b=oqGLwduMS7GcDsqiFOxtD3FYFR377OEW2vxY2bT+BW3ZoN0lls/7bg4wU01nR6xCbA
jMWLwb3TODlAOT7pZ6OOZ4UbvehYctOcLiCd8jkJCV9KUTz4sO+4+waqv8IeCimSz9/8
fPsuvouqgmPUCaH6atwN8b1MPk8NlrmRod5es2NBFmhbRB+xIwWRAy2hUL+SBDcI4n3A
sD5f36yHIBHex9yKrbL3aElck9HO05KafQ7Jw6VS56qnf7h4rz6RQNwzw3nCcWaxRUEk
iSMsH3saRGH6SITVY9mKSABPxblhU4OsNAQnyyFUUUqaFbEzVfqtwqX8lCcytnQci3uS
9q2A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796389095; x=1796993895;
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=Oa+J//Dv+4Dzdu/avxmTCwmzD3lGICP/yQrhSH28DTM=;
b=Lrf8k4PbureDd+x30Bzz8kc8lCK63I9Jk+zOzuatTRByO9uSez96HU3pbKz2ng0QtZ
/U6npV7FTR9lyOJkPImkRdS2ve7P4z6hjix0rVDgyEhHVVDCseG0HHfHdKMGWkw1LuY7
XpunrEfM++z3kWO8e0uyrSs5HVaMcUHwISPte4uGjZLDWF4Q+CjYrUXOpMWOvY9wRdax
xos6R60bwpKc30r7cUJ5PaIyC/i9+OMK4IFjLCr6yQclUnCf9cKRsz8iQFyA4jso4rNE
3IFZ/jINjghVUynL9lXu+GEGTgdJMsukEsERxZDi9iDaqtrsWcHNOkCYkYZIhh2p6DF7
5sIg==
X-Gm-Message-State: AB4q+uEui0fdijNIM6FQhsC9DVjaD7sHIOITrlJxXRfD9ySzsCuqzbTH
4CwdaJg5LFli7Qqjd0+/SgcCsBc0b/kIHVkg3wqj/QTK4Ja+3qj4Cg8aVjkeYg==
X-Gm-Gg: AZFdTZfxTp6qsQyl0zfjMOIGe1sHFA6fpWZbXFzKcVbK1aM00uFiHTiX52AnfQRNUXG
s5GpcxCdpQNpq7hroksRwBjQhkSubkVsEYNIbpvK1btbRO4sFWnIWdWbGcOjWWkhdRMvR/vk+la
CPQc48FVaN4Rdu+6c0eTaFEsiGeXWAO3rA/ZanbtRbapQvMDsEdisEAxALMT9I5IVZQSQXKGA8S
Roni5rEEV57TD8hUJF8ugWOvPsSwqmEBDWWpQUqbs8sOekOsVZNrDC89xzRs1RkOOYwgDqlx6Mx
+leQjZlPpgNYzDIhW+7RL16StV3nH00L6jOALJfYotqyT1kkeYFhRpTZvSNYbWGMWC/liBka8Lh
JZCi4YaDiTDwJKcliiDbMOrj5Q/pPIzSHDxHMCcV0gaVQ40Kmi6MynCC5wpZHklRIGuhwGiK0BS
7aOA0KALtYeHBkfFSsyT4r5kPsnnu6vm/Ts/HMLFJ8aT1UUNhDFZvhh3PCg8CClWQWyjUl8Yguu
LflmayBoJK6lkTcGg/IjpzugxrJJ+Tm5J6fcwH2AHcTtZLiK0SMbzPHI4XGIdNiiLK0ogK2dq2/
TOyIGSaRZZckiQKAfTLGl0GX3UrnyALE
X-Received: by 2002:a17:90b:1dc1:b0:3a8:545a:9e87 with SMTP id 98e67ed59e1d1-3b5e061bf17mr1657228a91.15.1796389095288;
Fri, 04 Dec 2026 04:58:15 -0800 (PST)
X-Received: from [127.0.0.1] ([4.149.246.120])
by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5ddb881bfsm3935438a91.1.2026.12.04.04.58.14
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Fri, 04 Dec 2026 04:58:14 -0800 (PST)
X-In-Reply-To: <pull.2509.v6.git.git.1796389090.gitgitgadget@gmail.com>
X-Fcc: Sent
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
X-Cc: "D. Ben Knoble" <ben.knoble@gmail.com>,
Alessio Attilio <attilio.alessio@protonmail.com>,
Alessio Attilio <attilio.alessio@protonmail.com>