From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.182 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796389095; b=eImvW1ES46k34z6R+JsfZNkio/lc8V5msWWDotab/QUbk8QhFJJWO7lR1RWkUgwyOUNX Yf1V0CymRuq3LCXh/t5S9rcx5b2xryD7tj/3ilFU5oADK9ivQK4R774mNrDVwOJujPKqd V7IcwZgvn81X1tE7mBFeannZ2y5frAZJdoH9LucDNymCRglfbsoSy+nutYF9geieD7Tcq 35QJibvzY52wiXXcf6Ndj1l9QgX3qGHnKfPGgfRtr/mapA4FM9/ADAv2Q6iM5vTaWtaNG 58bYskvz9M2ysiL6Yz+AufC4EQ0lOARN3uNqV8aEr2B5jxDjDSVidwMefDNOvvl1ShA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389095; 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=bkbEghDu3gpm8U3Rzz8kUaw2lYqcE9/mTiXsF7lyzBY=; b=J1oYLNUgsL4mOW4dcUfOdsG10+sbyD+xvHJuBQdWP0aAs0sT0q7V38JyQ5kn2Jqk7J9y NHUPNOZr6IxgswNMvxvELxeL4yFK6Afi5CO4C/QgEgH0ZP5n9OfYWBDVrMMK3jAyJlWhE oL/jSKp/okJ+gHI2sdIwcJN7vy8wLmprVBlVOqqUsxSgFRI1fn5xDz48ur8dQvtBAolhv J2j7quAHH2C+Xbk6k5lyj/NvrsMXaH/uoQGEmQfBiYbwbN4oSI2RZoL8xz1MVST2U/VLe YGsHnoHmLYT4lq7Imuz3uvftTlpKJ4cKO3mvo6wel1+Q9LLqTkDDOZNaiCqEZ3+9EYg== 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=Iq1fUi7I; arc=none smtp.remote-ip=209.85.210.182 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (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 04985606A339 for ; Fri, 4 Dec 2026 12:58:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 04985606A339 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=Iq1fUi7I Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-8a070781f63so475472b3a.1 for ; Fri, 04 Dec 2026 04:58:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796389094; x=1796993894; 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=bkbEghDu3gpm8U3Rzz8kUaw2lYqcE9/mTiXsF7lyzBY=; b=Iq1fUi7IURK+iwbayB5CFvGzW2tYBQPSY8WCMzGH8R8YIEYN/7ckrFBOE81fBRmy4b UKt47/P/toEC3j8zOBszLRIaRIXSoGaEQwcfoZ/cvLi3nNAflobxh7bglXpDeOSRbSTz NHcG/DWnCOHJKCIBzGztJkTy0atT4nkJvtKsk9s7Xi0RSjhhavgQZOwsEniZ7YwkGcqP p3y+hhCbQFgl1PqG6D07nHXgRWaY+I2tTwoZ6Bd+rYKVqYF7RzXkWQlyX9dbT16Urhue g1oW1Riqy4Ae6isvKT3XYMyQN0FZAcm1blhyN/af+ajkOj+Xz/V8B8YAA9gkQsNxBjVZ Xi9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796389094; x=1796993894; 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=bkbEghDu3gpm8U3Rzz8kUaw2lYqcE9/mTiXsF7lyzBY=; b=F6dh3UwxwtMJejsImf7eixoLkdtmz6yOVDcdqptxT5319Ry4uoC3FuQN44eW2NfNV6 bkMzHrDKz8W2E4B6qDTUpEp87gmIGY5MrYVIB4KJGH2a2hbCat5vziJbBBXx+tVLg7hV V2iRTOGV+NUVkqi2jlqFEff9YdtbW4PVcZ/SjXz7La7aEI3/Bo8SOmQgI+Y5IkDviozv 9xEJALPyO2hNaYHo4+Tl7BOx8Rh7Iwp8V2vkLeqMb5vP5eRPBDs/V7Dt42t3hGlPoRDW M6Qyl1gSXMLK05x3J9QWUXoW1emCUg4pWA6NceOmQRdYBTiZIHuGUlGprUc3jRg5Np/k wH7w== X-Gm-Message-State: APuU4Z9CkPqhIfApG6qCRmdKqElFOzYhTFrHkc4CrIRo8GXXFcpx/xvg Fz3xRP1C26I5DYHqe8P0w6Lt75FCT7GGFyfXe7+R3l61ANJ+A8BGs9xFmOiXAQ== X-Gm-Gg: AZFdTZc7P61stns8nLu9OZ7pKDm+DECRP2fno/V8iW0wrVR+AkknIKkajP9SiAVcpQj VdDIslLSTKmF/rHEiqKEaqyki2kJpaOi29+aVAkkWSxm7ci66tSq+5pfsH8vFjlmOjwRJb0P6vB 9nX7vjw6eglw3aihx2OCN5B8JyLpvjg57c3WRFjS2CksN1RHvDU+6M95pbHtPZY1jHGnjJmwv7u YdehYUYayBNi8XbdfIkG0DIvQUXsrC4YKo6ChqjR7SQdcOVOsjAbntjf2JgnSv7KvYcIqlqfft/ j5E2LmFMYATZvVCcOQSxqn7yJjinoWNlekjFEH5XhD28rj+qNmyutxpuKfBM2dAI5kRV38tuUYe hzQ5leY+kLtdx+VtmurXgQkm+eY8y6eODfU4B4RT5V4lUhbZ0h0wExcoocqs8bgGF3iAo0BFnE+ t8qyEDZd/7dYpnRuFeDjD8qukSpomFZUrzK1Tf5LSX+ZnJl22Y0yaAHNaqSn64RgqEBLzwKJHQ5 EX+t9AWz147liFY9n0mzvXTsE/GmFvK9Ee7U7JjGX2RWZW1bOwQzAtpTXhO+hFhlc5UtkmnXTRu xVniC6Q87VFRs7O13LV2Oo9KSA9TuxY6Bw== X-Received: by 2002:a05:6a00:9519:b0:891:6aeb:84fc with SMTP id d2e1a72fcca58-8de2d12f91emr1669549b3a.22.1796389094239; Fri, 04 Dec 2026 04:58:14 -0800 (PST) Received: from [127.0.0.1] ([4.149.246.120]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8de128bf13csm1476225b3a.28.2026.12.04.04.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 04:58:13 -0800 (PST) Message-Id: <123289e0f91c01ef56abb6064646db5fbbe8b44e.1796389090.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Alessio Attilio via GitGitGadget" Date: Fri, 04 Dec 2026 12:58:08 +0000 Subject: [PATCH v6 2/4] status: warn about submodule URL mismatches 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 When a user changes a URL in .gitmodules, the cached URL in .git/config can remain stale. Compare the URL declared in .gitmodules with the cached superproject URL, then compare both against the submodule's selected remote URL. Warn only when the submodule remote matches neither URL, since that indicates syncing will not overwrite a local customization. Emit the warning on standard error for long, short, and porcelain status formats. Respect pathspecs and suppress the warning when submodules are ignored. Signed-off-by: Alessio Attilio --- builtin/commit.c | 1 + wt-status.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ wt-status.h | 1 + 3 files changed, 56 insertions(+) diff --git a/builtin/commit.c b/builtin/commit.c index 36e47e18ed..577b097aa0 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1636,6 +1636,7 @@ struct repository *repo UNUSED) s.ignore_submodule_arg = ignore_submodule_arg; s.status_format = status_format; + s.check_submodule_urls = 1; s.verbose = verbose; if (no_renames != -1) s.detect_rename = !no_renames; diff --git a/wt-status.c b/wt-status.c index 238bb48643..bbd0e082dc 100644 --- a/wt-status.c +++ b/wt-status.c @@ -3,6 +3,8 @@ #include "git-compat-util.h" #include "advice.h" +#include "abspath.h" +#include "config.h" #include "wt-status.h" #include "object.h" #include "dir.h" @@ -23,6 +25,8 @@ #include "remote.h" #include "refs.h" #include "submodule.h" +#include "url.h" +#include "submodule-config.h" #include "column.h" #include "read-cache.h" #include "setup.h" @@ -2692,8 +2696,58 @@ static void wt_porcelain_v2_print(struct wt_status *s) } } +static void wt_status_check_submodule_urls(struct wt_status *s) +{ + int i; + + if (s->ignore_submodule_arg && + !strcmp(s->ignore_submodule_arg, "all")) + return; + + if (is_gitmodules_unmerged(s->repo->index)) + return; + + /* + * Sparse-index directories containing gitlinks are not collapsed, so + * every gitlink remains visible in this cache iteration. + */ + for (i = 0; i < s->repo->index->cache_nr; i++) { + struct cache_entry *ce = s->repo->index->cache[i]; + const struct submodule *sub; + const char *config_url; + char *key, *gitmodules_url; + + if (ce_stage(ce) || !S_ISGITLINK(ce->ce_mode) || + !ce_path_match(s->repo->index, ce, &s->pathspec, NULL)) + continue; + + sub = submodule_from_path(s->repo, null_oid(s->repo->hash_algo), + ce->name); + if (!sub || !sub->url || !is_submodule_active(s->repo, ce->name)) + continue; + + key = xstrfmt("submodule.%s.url", sub->name); + if (repo_config_get_value(s->repo, key, &config_url) || !config_url) { + free(key); + continue; + } + free(key); + + gitmodules_url = resolve_submodule_url(s->repo, sub->url, NULL, 1); + if (strcmp(config_url, gitmodules_url)) + warning(_("submodule '%s' has a different URL in .git/config " + "than in .gitmodules\n" + " run 'git submodule sync' to update it"), ce->name); + + free(gitmodules_url); + } +} + void wt_status_print(struct wt_status *s) { + if (s->check_submodule_urls) + wt_status_check_submodule_urls(s); + trace2_data_intmax("status", s->repo, "count/changed", s->change.nr); trace2_data_intmax("status", s->repo, "count/untracked", s->untracked.nr); diff --git a/wt-status.h b/wt-status.h index e9fe32e98c..45eeb8b558 100644 --- a/wt-status.h +++ b/wt-status.h @@ -123,6 +123,7 @@ struct wt_status { unsigned colopts; int null_termination; int commit_template; + int check_submodule_urls; int show_branch; int show_stash; int hints; -- gitgitgadget