From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796159345; b=vPMIYoJV3nNxPGQkHde2wQg6k71fpLlKIfhLQKzQNc514/kTDU0SJxwHovcmsi2jBICR exJyPRiZH6oaXnNkv6vRCyDgqTkx0LvGETmlWXIqxH9kLEVw9P4+nuHvy6uD/I/BQVN0+ Wh9d+MxnLJ4CIAZ5Pige0aaCdz/6uG1XCNsaigGyKI5wSalQwThe7OWMEBbIkFjPPRGF6 PcnAmlW0FVaEH3w2uEpWYNLRbT4l4tk9FzBCQCSsPbWKsv7l4d5K13g+u6cVVzoFUlRp0 17alRrnDTHyKnCwYg8B3KylNrMtmW3xjkUnlIJYDg6uCBhbltRf81FXKAdAblr86O/w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796159345; 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=PEIwaAlUsdilpWoK10F35yumi8smk2q7mqbO0TSReko=; b=KUdqvJ+5pfkzb5UXSz1x8Wnd0TkDV0rsy/eq/+mgYXE34pLOqi1BzkvfZk5DDoh3sSS5 BA+l+aLh0jKrFPGKH4RJOAl2ceMm4d3sRV+wCsHZUI79jfI042iyj+RNLOZU6DuJHjeRH wOrZBnog8PrwvJxjvFxu1rAhLCk8qCbLeaLZRxjwApqvZbeBcFisKEGV5U+Yfcp3TRgTE HvH6oZB+eyZllN1D9HDezVy9bUeHKQcLyz+98NdbuvZHlbecmJxRqqoQXi/umbLwSajoe aECCJyFx8s4OFbLQiMKHDrJ0YAT+aUs34uWcqgTlgEz1G3hNm8wJ+nGOQakurQ4DmnA== 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=EUZACRUC; arc=none smtp.remote-ip=209.85.216.49 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 6D156606A329 for ; Tue, 1 Dec 2026 21:09:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6D156606A329 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=EUZACRUC Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-3b564fe29cfso1795033a91.3 for ; Tue, 01 Dec 2026 13:09:05 -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=PEIwaAlUsdilpWoK10F35yumi8smk2q7mqbO0TSReko=; b=EUZACRUC9vbxbD6nGllwlMRhDLyF5PWH3B6hKRRWu4+F9D6WquWUByFUbRj8pvvb+5 4aGK8AHB6TYZ5Nim9qVAmAMJq362/55yqt7xqy878pOdqZ74Ep4oz9IloQum0bSHWs91 QwIip4daK3xAhKlSeHiIqsdhZiLl3Ojh92x8SUYAgRKwEweszI5OPui499heERdMTWrR 9Z1rztgnNTGUYOWO3JAh7XBFeImG9FBwhfiXO7VObE56pZC+PxFKTL+8ckMrLbDk7sKy Dfk12rgAJInYgvfmyGiLS/l21vmnyU4+HQGmlaT7Usnu/dgoorIr1uNSkhJukppd/MhJ m3fQ== 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=PEIwaAlUsdilpWoK10F35yumi8smk2q7mqbO0TSReko=; b=xqT2MEXakE6Kkb7uHL8ozLPHZGXMP60+pmK5TDnghne6kN2eEJyK9u4jPew3TErSwq x2X/Q/RcDSpfgHPNOlb1XPG2V78xKtVyPhs3+TAV37bnpn2XbRaE0T0TBNmfq88OKjoh 0EA20nxmf7cihJZGIbzt/0t1VRgoRyEL3lE+1PxoMxENncgcLgL8JIIUHUOg2ArBtY4m 3mzULORB+XQKKYnvPG6/iT4K5oM0XAtT1hB6w/pZtJ4cMBkHnzrJYLKrlGzMYlwAVJ79 QpWA+Xmef9t6VkmOSodlBIHnynCKSNVVIR73xX+BOBXV8B7vYCcgazbqhNAyKeZUnKzC av8A== X-Gm-Message-State: APuU4Z+Fi0vA8GXJVsXkcTthGj5V+QZmjBKkzwyOWJobs736pj1Zy7WH 6RZh3JeZZvaNDVJxgpxG/dIezUyXVN7nEvaTgYYgs/1BnnIMSTCdbKm7fX7+7g== X-Gm-Gg: AZFdTZcEy32G3MskgfvBwpVrCZDC8MVWNzLj1SMqats2UAsM+lWUl5abkr/ShkZ+Xrh IM26wybe5Qhm+9lMlCz+pQ5rXJUG6VtruX6yW/tKou4N5rr4eS6a2KgYGf8wXMf1UrwRt0jdEkb Me9CjmvVjDxLGrgthbX4uLkou8/8fZUTAJnzwTdS8ZKozOpYCR+2Vsv/YRxw+L+PTmlHYHFsJCl lLHtJjnQAujpKx7PWQ7RzTJ9dGUmekwYCp3AxZx6oCh8aXdyGrKIkXQadWboWCDuzhbXQuS9UdM G/JDckX9dmzbYgR7VHR1kIoJlwAnc7MWTf8I+riKYXJ1IKATfeMxXBBem6OOiCelQjFbT3PuQHe nLAxvSbv085Es38jJBPZQL9KJg4nAqIPZspS1pz6X2Ec7AhPl1o44v9freJZjL1WXWwihX7dBM5 /nZ3NlQflEpfs3Vh4YpZ37OT0IecMFOBBqJH9gDDOQjNlT4Bmp0natb5b7LdVDK2fkzpylh5z57 8J3HcgkVNvLBsmSqj2fLdQIzjprdR7M2B10uJ8iYhDw46/zJs7YuyFdky8oEAIu1C5AWmPCuJnF HiI+GetnFEmkRarTtYqmVt0xGAcp+UxaxR5QSUxFvDWGKbiUHdeCWJPx1K31UUynByro/zfiOfX zFvxquko= X-Received: by 2002:a17:90b:1a90:b0:3b0:9941:8d42 with SMTP id 98e67ed59e1d1-3b41c92a1c0mr36825754a91.33.1796159344388; Tue, 01 Dec 2026 13:09:04 -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-3b409330ae8sm62316644a91.7.2026.12.01.13.09.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 13:09:02 -0800 (PST) Message-Id: <6db7dc9415227488ddf422d35802a7c9569ddfa5.1796159338.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Alessio Attilio via GitGitGadget" Date: Tue, 01 Dec 2026 21:08:56 +0000 Subject: [PATCH v5 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 and status looks clean. Compare active declarations with cached URLs while printing status; honor pathspec and ignore options. 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