From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.176 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796159346; b=igI20dNMrdBLwN9XUfYZLZuAAccSm4RheNbAw3nLqoHa6sxEXOJl1gOn2is+S3gESZgJ gu6JzJLVRwB4wmpCKqvmX45nilmREECjwL3MhK2Ytv22ogr3y5ecJoxIRtZDx+uVoDo3Z jBNBbnKa/L/iLK+9umFXewAg4G7PMRIOHen01j3ei+N4zAeu0b0nfJErq8ZXQU+4xDvKz AMOY1cQiWPVPG6r/Uzx7BpkLLj6PupwnfCFs15UHI3UI4TQ3VLETKobhdcLZyBhJS+pd0 Utn/hve6jxRGXEPSa95tlKRcSYbc0/qf9nA5Ukqg9AR/EZ/a9gX1/YJdXrujJddbRFw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796159346; 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=CDG4f6MvMjXEuP8qDS5ESdX+AyOTSEyGI83j0rU6FeLK/DidVoxEFJMgevx4n9z826nk JvQAXE341/uHtcgI2OnLz3RreOkua13gas0GgsN+cLOaIV34vY4/93SrxBAemzW6WWoMw 3xgfG0S6C2ZfhDE/Cg8oSyMTQ25svixZwhd1k+Jj7bTYUpbiAKwQE6GozCQ7hdQIj/FGK fyXPD0mM5ueOG4KXmdgBFYtHqi5DBAjkk0C1bD2Ow6pkfnLtjjjsd9xEjKZIW32ZBiws8 klGL8sH7BaPx2YRj/kuchfiFD4eA0iRnGC4Hc1FtvmQUSHAW0UfAV7KvKj6htWo1gkg== 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=HZ5mHlDn; arc=none smtp.remote-ip=209.85.214.176 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 41990606A320 for ; Tue, 1 Dec 2026 21:09:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 41990606A320 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=HZ5mHlDn Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2f041f88577so66749145ad.1 for ; Tue, 01 Dec 2026 13:09:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796159345; x=1796764145; 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=HZ5mHlDnwBuF9lpM1udhro20zayJ1LiznzuaYTFaXFzUh1JCgl1ETdnMqetx2KYGf0 TXa0TiIsQqXD+kV7xeAZAWhL8Dl1ZdOHhWCxByMmiAY3EtVMaUoWig+D6gl74aAM0HbV U+orYBDjS2wiQ3z6tVVT+kku1uFeT5mqr0CrzOh8r3ZzYDrwSRF/hLDlE9PWzUio76tT tQp7WB4JXvfm48wIJAreh+NKoI7bZYSJ9cjKmY6DtNO9Ze9YHeBEft65sMRrwIQPkQ09 61ShksWLar2hBWT2TEvj9O6t+YcutSzI+wl7Q+vOzutD4Zmpxrf7SmluAUf9tfa0aC/H RnOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796159345; x=1796764145; 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=EcBPiSeqpMWmhV8Mk0ohmp3TVDGwvoK1RrgsVEYLBKM4tMYx3qUgGmzidV22fsWGVO aZrb5vqFPp5AHOZ7dZwpDFw4PT7mdmsH/eAhregSBphI/N8qWILSatS8stXc3NVZQ0Sl vqYG1ZIjXB0766L+25fw98BderbuoC9xceSB1TuExk5cUI7HPHkBo0nfhZwt575nGC9S 6wmlxwrggg95chi7Nyyvm9UyaWdGmQyHpJ+GNQLTBQYNsb/HJ9D2zxs6Zw59J4bos/ig afDSQfIzqdPUD20AfK9m42a2gUK/0Zwjr4CwvHkoimrdWiniCmMtGP2rjhlXv+9NOHf6 YHxw== X-Gm-Message-State: APuU4Z/1EL5k9x9FGEDWQC0DorcjhIp2Wg26yRBxPiPHpS9cGzl6lKkd ERmpHUwnoo2XjbPso4bwHEBX+evK6UyaeLYgv3JLMxJ0qT65XZVxmRUZcTIPTg== X-Gm-Gg: AZFdTZckgLbG51aMwY9nZymdVeY72psgNuExcstf6iObbvJe8snxKn0XjLgqlFyyEy3 0XJsHS3E9qEr149K9F21U9T6z1juS1ymj1WXm+n5LYKMtbYAlt/JUmCuUG/0DPMQA4hajzTaVvW 45+QZoF4wG73Y25lsCfSLDa0xkmzjQkVDANuLzaUghgISNHpA4Dnmkx0EsborFYxrwBJVN/0gpx vDTjRfQczzexeEywTMNsy5u0IE4zhs+ZxSBsLXuVHnYeq19gNpgN2dFmWh724+eXRwNq+cUHWIO FM9Yyq9R3MgMcsWjKDHCEeOeYYSeyisGQaPQQR6chjbXEjuDEwPk0ewOW7WxB1jW96Kt+Q4DP0i pfclzrmtZdSaaF2Q+j8U+KjZ5zVhjeDCLntgPgO/8vDDRuTX1FMtYFCa87SkUYY7uxR7cX/bIkV ZyzgwfXMjc5MwcLRVO5KqXiPbhBBRrdTz0bbRvGHnsUs7pUrVgLKekivQDJJmxUd8GNrbm2fEL6 L/kjplEhB212sKQH8FEBwdBYAMEF41pWkUPgCRZNmLLvbs8yLYdCTSNbp9pQbFlO3GOWrkSzCc0 pCXnVAFuFnSuNwyP5uVc8uUDO4M7aNW5XJiBar99tXnGZZSAa9dAe88lgGPFrVX4S30AvEmSA0S j+Pi3wEY= X-Received: by 2002:a17:90b:4ccb:b0:3a0:7261:d58e with SMTP id 98e67ed59e1d1-3b41c8dc8aemr38578215a91.22.1796159345385; Tue, 01 Dec 2026 13:09:05 -0800 (PST) Received: from [127.0.0.1] (ec2-3-42-157-20.us-west-2.compute.amazonaws.com. [3.42.157.20]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b4dfbe54a2sm40441213a91.17.2026.12.01.13.09.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 13:09:04 -0800 (PST) Message-Id: In-Reply-To: References: From: "Alessio Attilio via GitGitGadget" Date: Tue, 01 Dec 2026 21:08:57 +0000 Subject: [PATCH v5 3/4] status: preserve customized submodule remotes 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: "D. Ben Knoble" , Alessio Attilio , Alessio Attilio From: Alessio Attilio 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 --- 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