From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.179 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795884826; b=5OJFTsJyL68bCXqzjqXKXeXemiFXAzuEYi5SgZyRpLQpSBVSWgxPguLMkjtqWENBzLK2 iEubYRIcv9qqeCpmlo5d8kgFcvRBsMnr+RvFRO5ZHJrLdknOtVnzVzzMwIUl/Io8WbsQE 9KmkO8pzCWOg6UsOYWSTAHFPCAH3L1XS3aAcweGH+2t2UxKF20M8ogXzuoolOrNlQkAI4 4MoOHnydc1sI5u+OYEDSwoULyhzvswkAKhLYTACoNXWp9kR6ygZ/6uasRffrtRGylWrJs iJ+bOwjfz3eUffc6E8Da/buDufus5FORuQDWiIFI5rTAictBOGXF0W/ZWxe3jacKwVw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795884826; 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=EC/E8ReOAf/IAHNleF4J0Ggkj/XIGvyBk0yeBdbcUK4=; b=xL9DQWR2yp2C9HaM4jnmsUzCXmGyDmMr8PeK7UZIItsGGoZTJWHOqX3srR6s71DQ1qVu IZX+QZKoFxS2P5hf7k8cEwL45tGEtvCcHSeitapTfQUTuCYMDAOJrEfVCNUlu0TXhxONs O+LqB6EWuyx8jdjd7g0u78r/Bg21HX8LCi2Ol1u6ZyOs66Y5KqmbHiPTsYXeeu8wyzJmp hV5PHtymbd/sRiDP2dLblc/YAzxmSeqJ8HylTA2VhcCFS0ARTwPW+eiXeuVNrvXD5ylhf EJGuDRxxeJ0sd4Tfpf3eFOsg1dgFn8v0YLdR/6BqKaCuTqSqf0HyPA+Z8UwEgM+M0Xg== 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=d98EYJbY; arc=none smtp.remote-ip=209.85.128.179 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (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 B0AD1606A31C for ; Sat, 28 Nov 2026 16:53:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B0AD1606A31C 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=d98EYJbY Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-8b4e18369c8so54037267b3.2 for ; Sat, 28 Nov 2026 08:53:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795884824; x=1796489624; 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=EC/E8ReOAf/IAHNleF4J0Ggkj/XIGvyBk0yeBdbcUK4=; b=d98EYJbYqYj20Pf6bSW0JACuaMqINnSus0lKLl+vR88giYERAu2swSbmli7LlCZpg0 L5fVOfIAFRh65gNj7SozrC0iM5OMtUkpBYb47/SK+qh7KFy6xEUjRGG4wllUaTRN46Fw Erq4urCmWSbnhSE0ugPrgbVZzdpJkckaYLf229jgZcktdIZ5O7WUCRsx9E6Rt4PlgH9V tcEq1xMJO1JXBAsfX9P9TjeeT/2KMS4BgBvG1Gs46qWz0v1rV0XsPEUsvOFkBEU6dbhC REds/tQFfpnfutGmsLqcyBPIL2ZR6+t/Bga0egUveYNERoCX921CUCbsX0MB+Ap5eXnS 0PxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795884824; x=1796489624; 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=EC/E8ReOAf/IAHNleF4J0Ggkj/XIGvyBk0yeBdbcUK4=; b=pslDoTFmo8yl+SC3hkkS/vyugHpzbILQA6GAL72pFtZl27pjnMwu3qB05RItO1UB9d pJCcGmflGBQ6yJ0scvE1sv3YoMtFDlxDnAcZqNYBUcDQjpT91zndYUElAz1UPOtgQqTO El0Bk9QlQyUUEjPFEyglRrMumjesQzOD1ylQcwK/aHpIweeUGYNxLWBo8PwyjyZI9tf0 SV6BnvKdyGIUC34URibyKqKFvFh+1QdBdPBEA9OC4DlcV7Jy2ic9jcTQK8UZoMUYED+F KDkK2+wVYnaeKHSJ55Bvlqtxm+C1DZgF96A7cw4JjuT3cNHoS24mMFIeZbw2xu2YnR3J Cp5w== X-Gm-Message-State: APuU4Z+S3z8bANyJRCqSx1gGpunlzLHEY5THS4k7orv6rL85vKK3xH9O UZYvFgFVN0CsBEP51xYcF+c4PYRrhszWoqrrZlnVu9Q9yrLMGAJ9D1qUGyM8QLUq X-Gm-Gg: AZFdTZfUdEN7klvTzRCVwyryZthjXdJgV9pN5PiVlfHubeA+qEyfmucIdxU+zWEWQjg uccvHVSPpJcvDsfH5Guzaw4UxIJIY+uA0EPG2A8Z3fp7ln9Ls77UmM7QxCYb9szqbO2/xRqZX86 AgyXMd7BGObCXC1ia/vHns7hcIItQXEjiOgSekyb6qLDHMNO+zM+yN5KEAcERX4llAK6hddU08I 4hg5QmnoeqZh8RGhkSytQV10I1W+dqgYnPf+lYpmyXoaVs5jwE7lGfLZuZ5kieHVUh/E4m06XT/ l00lxFymMCLUW+EnOVLk72318mQtWY+BaLCwH2DW/wjMyIlDVF51fKsZDuVdtJmfF7rzSV8IbXl KRzXNWXslJSkeCedztBjhnDGdiKSmW5vqQzZZA/OuqS2DbNvIYrtNYFfSqrkr+cODiBI34Nfi8I ZOVJNOqharABs/BXjr0XPq4iMao3Yjs5GQ5L0XiiEufJaL1kKyh+5bVE3whhIYKpQ716xRgn63I JLDe4ducqpsoVuWGR0y//Q2XZamN2dwtiXkwankOn9Lo78Rps/bYFMehOEiN49QGzgw8L/4AdG0 ZOLHc226doZH98CKcNWephu6wH3VbRw5v109gflYr3AaDgEtkiJF2iY= X-Received: by 2002:a05:690c:b99:b0:8b4:da1a:8f6e with SMTP id 00721157ae682-8b520436e71mr95134457b3.17.1795884824424; Sat, 28 Nov 2026 08:53:44 -0800 (PST) Received: from [127.0.0.1] ([134.138.59.129]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b56fc6131fsm45967267b3.34.2026.11.28.08.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Nov 2026 08:53:43 -0800 (PST) Message-Id: In-Reply-To: References: From: "Alessio Attilio via GitGitGadget" Date: Sat, 28 Nov 2026 16:53:39 +0000 Subject: [PATCH v4 0/3] status: report when submodule URLs are out of sync 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: Alessio Attilio When a submodule URL changes in .gitmodules, the corresponding URL in the superproject's .git/config may keep pointing at the old location. This series makes git status warn about that mismatch and suggest git submodule sync. The warning resolves relative URLs as git submodule sync does. It also suppresses the warning when the populated submodule has a custom remote URL that a sync would overwrite. The series is split into: 1. submodule: move URL helpers to submodule.c 2. submodule: make URL resolution repository-aware 3. status: warn about stale submodule URLs Changes since v2: * Keep the helper relocation in a preparatory commit. * Move repository-aware URL resolution into its own commit. * Keep test output inside its fixture directory. Closes gitgitgadget/git#565 Alessio Attilio (3): submodule: move URL helpers into submodule.c submodule: make URL resolution repository-aware status: report when submodule URLs are out of sync Documentation/git-status.adoc | 12 ++++ builtin/commit.c | 1 + builtin/submodule--helper.c | 60 ++--------------- submodule.c | 45 +++++++++++++ submodule.h | 12 ++++ t/t7508-status.sh | 100 ++++++++++++++++++++++++++++ wt-status.c | 120 ++++++++++++++++++++++++++++++++++ wt-status.h | 1 + 8 files changed, 298 insertions(+), 53 deletions(-) base-commit: acba8bf9753134d9bde89f94369f775838a8c5fe Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2509%2Fkairosci%2Ftopic%2Fstatus-submodule-url-sync-v4 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2509/kairosci/topic/status-submodule-url-sync-v4 Pull-Request: https://github.com/git/git/pull/2509 Range-diff vs v3: 1: fc300295ff ! 1: b09e8501ed submodule: prepare URL helpers for reuse @@ Metadata Author: Alessio Attilio ## Commit message ## - submodule: prepare URL helpers for reuse + submodule: move URL helpers into submodule.c - Move the relative submodule URL resolver and the helper that computes - the path back to the superproject from builtin/submodule--helper.c to - submodule.c so they can be shared with git status. + Move the relative submodule URL resolver and the helper that + computes the path back to the superproject from + builtin/submodule--helper.c to submodule.c. This lets other + callers reuse the helpers. - Pass the repository explicitly to the resolver instead of relying on - the_repository, and update existing callers to use the shared helpers. + Return non-relative URLs unchanged before consulting remote + configuration, so the resolver handles every URL form itself. + Keep the repository parameter change for the next patch. Signed-off-by: Alessio Attilio @@ builtin/submodule--helper.c: static int get_default_remote_submodule(const char char *oldurl = url; - url = resolve_relative_url(oldurl, NULL, 1); -+ url = resolve_submodule_url(the_repository, oldurl, NULL, 1); ++ url = resolve_submodule_url(oldurl, NULL, 1); free(oldurl); } } @@ builtin/submodule--helper.c: static void init_submodule(const char *path, const char *oldurl = url; - url = resolve_relative_url(oldurl, NULL, 0); -+ url = resolve_submodule_url(the_repository, oldurl, NULL, 0); ++ url = resolve_submodule_url(oldurl, NULL, 0); free(oldurl); } @@ builtin/submodule--helper.c: static void sync_submodule(const char *path, const - sub_origin_url = resolve_relative_url(sub->url, up_path, 1); - super_config_url = resolve_relative_url(sub->url, NULL, 1); -+ sub_origin_url = resolve_submodule_url(the_repository, sub->url, -+ up_path, 1); -+ super_config_url = resolve_submodule_url(the_repository, -+ sub->url, NULL, 1); ++ sub_origin_url = resolve_submodule_url(sub->url, up_path, 1); ++ super_config_url = resolve_submodule_url(sub->url, NULL, 1); free(up_path); } else { sub_origin_url = xstrdup(sub->url); @@ builtin/submodule--helper.c: static int prepare_to_clone_next_submodule(const st if (sub->url && (starts_with_dot_slash(sub->url) || starts_with_dot_dot_slash(sub->url))) { - url = resolve_relative_url(sub->url, NULL, 0); -+ url = resolve_submodule_url(the_repository, sub->url, NULL, 0); ++ url = resolve_submodule_url(sub->url, NULL, 0); need_free_url = 1; } else url = sub->url; @@ builtin/submodule--helper.c: static int module_add(int argc, const char **argv, /* dereference source url relative to parent's url */ - to_free = resolve_relative_url(add_data.repo, NULL, 1); -+ to_free = resolve_submodule_url(the_repository, add_data.repo, -+ NULL, 1); ++ to_free = resolve_submodule_url(add_data.repo, NULL, 1); add_data.realrepo = to_free; } else if (is_dir_sep(add_data.repo[0]) || strchr(add_data.repo, ':')) { add_data.realrepo = add_data.repo; @@ submodule.c: int is_submodule_active(struct repository *repo, const char *path) return is_tree_submodule_active(repo, null_oid(the_hash_algo), path); } -+char *resolve_submodule_url(struct repository *repo, const char *rel_url, -+ const char *up_path, int quiet) ++static char *get_default_remote(void) ++{ ++ return xstrdup(repo_default_remote(the_repository)); ++} ++ ++char *resolve_submodule_url(const char *rel_url, const char *up_path, int quiet) +{ + char *remoteurl, *resolved_url; -+ const char *remote = repo_default_remote(repo); ++ char *remote; + struct strbuf remotesb = STRBUF_INIT; + ++ if (!starts_with_dot_dot_slash(rel_url) && !starts_with_dot_slash(rel_url)) ++ return xstrdup(rel_url); ++ ++ remote = get_default_remote(); + strbuf_addf(&remotesb, "remote.%s.url", remote); -+ if (repo_config_get_string(repo, remotesb.buf, &remoteurl)) { ++ if (repo_config_get_string(the_repository, remotesb.buf, &remoteurl)) { + if (!quiet) + warning(_("could not look up configuration '%s'. " + "Assuming this repository is its own " @@ submodule.c: int is_submodule_active(struct repository *repo, const char *path) + } + resolved_url = relative_url(remoteurl, rel_url, up_path); + ++ free(remote); + free(remoteurl); + strbuf_release(&remotesb); + @@ submodule.h: int is_tree_submodule_active(struct repository *repo, const struct object_id *treeish_name, const char *path); int is_submodule_active(struct repository *repo, const char *path); -+char *resolve_submodule_url(struct repository *repo, const char *url, -+ const char *up_path, int quiet); ++char *resolve_submodule_url(const char *url, const char *up_path, int quiet); +char *get_submodule_up_path(const char *path); /* * Determine if a submodule has been populated at a given 'path' by checking if -: ---------- > 2: ad4dafd82b submodule: make URL resolution repository-aware 2: 9dc6283075 ! 3: 619101d5e1 status: warn about stale submodule URLs @@ Metadata Author: Alessio Attilio ## Commit message ## - status: warn about stale submodule URLs + status: report when submodule URLs are out of sync - When a submodule URL changes in .gitmodules, the cached - submodule..url in the superproject config can stay stale. Warn - in git status so users can run git submodule sync before a later - submodule operation uses the outdated URL. + When the URL in .gitmodules differs from the cached URL in the + superproject config, git status can help users discover that + submodule operations may use a stale location. Resolve relative + URLs the same way as git submodule sync does. - The check considers three URLs: the .gitmodules URL resolved against - the superproject's default remote, the cached submodule..url, and - the submodule's default remote URL. The first two determine whether the - cached URL is stale. If they differ, compare the submodule remote with - the old and new URLs as sync would write them. Warn only when that - remote matches either URL; a different URL or multiple URLs indicate a - local customization that sync would otherwise overwrite. + For populated submodules, compare the default remote URL as well. + If it matches neither the cached URL nor the newly declared URL, + treat it as a local customization and do not suggest a sync that + would overwrite it. Multiple remote URLs are also treated as a + customization. - Resolve relative URLs using the same paths as git submodule sync, and - do not resolve the already-resolved cached URL a second time. Emit the - warning on standard error for long, short, and porcelain status output, - limited to submodules matched by the pathspec. Do not emit it when - --ignore-submodules is given or when the wt-status machinery is used by - another command. + Emit the warning on standard error for long, short, and porcelain + formats. Respect pathspecs and suppress the check only when + --ignore-submodules=all (or its bare form) is given. Run the check + only for git status, not other users of the wt-status machinery. Signed-off-by: Alessio Attilio @@ Documentation/git-status.adoc: are what you _would_ commit by running `git commi +When a submodule's URL in `.gitmodules` differs from the URL cached in +`.git/config`, `git status` warns that `git submodule sync` can update the -+cached URL. The warning is written to standard error in all output formats. -+It is limited to submodules matched by the pathspec, and is suppressed when -+`--ignore-submodules` is specified. ++cached URL. For a populated submodule, the warning is suppressed when its ++default remote URL differs from both URLs, since syncing would overwrite a ++customized remote. Relative URLs are resolved as `git submodule sync` ++resolves them. ++ ++The warning is written to standard error in long, short, and porcelain ++formats, and is limited to submodules matched by the pathspec. It is ++suppressed when `--ignore-submodules` or `--ignore-submodules=all` is ++specified. + OPTIONS ------- @@ builtin/commit.c: struct repository *repo UNUSED) if (no_renames != -1) s.detect_rename = !no_renames; - ## submodule.c ## -@@ submodule.c: char *resolve_submodule_url(struct repository *repo, const char *rel_url, - const char *up_path, int quiet) - { - char *remoteurl, *resolved_url; -- const char *remote = repo_default_remote(repo); -+ const char *remote; - struct strbuf remotesb = STRBUF_INIT; - -+ if (!starts_with_dot_dot_slash(rel_url) && !starts_with_dot_slash(rel_url)) -+ return xstrdup(rel_url); -+ -+ remote = repo_default_remote(repo); - strbuf_addf(&remotesb, "remote.%s.url", remote); - if (repo_config_get_string(repo, remotesb.buf, &remoteurl)) { - if (!quiet) - ## t/t7508-status.sh ## @@ t/t7508-status.sh: test_expect_success 'setup status submodule summary' ' git add sm @@ t/t7508-status.sh: test_expect_success 'setup status submodule summary' ' + "$PWD/url-test/updated-source" && + git -C url-test/super status --porcelain >url-test/actual 2>url-test/err && + test_grep "module.*different URL" url-test/err && ++ cat >url-test/editor <<\EOF && ++#!/bin/sh ++echo "status test commit" >"$1" ++EOF ++ chmod +x url-test/editor && ++ echo staged >url-test/super/staged && ++ git -C url-test/super add staged && ++ test_set_editor "$PWD/url-test/editor" && ++ git -C url-test/super commit >url-test/actual 2>url-test/err && ++ test_must_be_empty url-test/err && + git -C url-test/super status --short >url-test/actual 2>url-test/err && + test_grep "module.*different URL" url-test/err && + git -C url-test/super status --porcelain=v2 >url-test/actual 2>url-test/err && + test_grep "module.*different URL" url-test/err && ++ git -C url-test/super status --ignore-submodules=none >url-test/actual 2>url-test/err && ++ test_grep "module.*different URL" url-test/err && ++ git -C url-test/super status --ignore-submodules=dirty >url-test/actual 2>url-test/err && ++ test_grep "module.*different URL" url-test/err && ++ git -C url-test/super status --ignore-submodules=all >url-test/actual 2>url-test/err && ++ test_must_be_empty url-test/err && + git -C url-test/super status --ignore-submodules >url-test/actual 2>url-test/err && + test_must_be_empty url-test/err && + git -C url-test/super status -- .gitmodules >url-test/actual 2>url-test/err && @@ wt-status.c: static void wt_porcelain_v2_print(struct wt_status *s) + remote = repo_default_remote(&subrepo); + + 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; ++ if (!repo_config_get_value_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 @@ wt-status.c: static void wt_porcelain_v2_print(struct wt_status *s) +{ + int i; + -+ if (!s->check_submodule_urls || s->ignore_submodule_arg) ++ if (s->ignore_submodule_arg && ++ !strcmp(s->ignore_submodule_arg, "all")) + return; + + if (is_gitmodules_unmerged(s->repo->index)) @@ wt-status.c: static void wt_porcelain_v2_print(struct wt_status *s) + for (i = 0; i < s->repo->index->cache_nr; i++) { + struct cache_entry *ce = s->repo->index->cache[i]; + const struct submodule *sub; -+ char *config_url; ++ const char *config_url; + char *key, *gitmodules_url; + + if (ce_stage(ce) || !S_ISGITLINK(ce->ce_mode) || @@ wt-status.c: static void wt_porcelain_v2_print(struct wt_status *s) + continue; + + key = xstrfmt("submodule.%s.url", sub->name); -+ if (repo_config_get_string(s->repo, key, &config_url)) { ++ if (repo_config_get_value(s->repo, key, &config_url) || !config_url) { + free(key); + continue; + } @@ wt-status.c: static void wt_porcelain_v2_print(struct wt_status *s) + "than in .gitmodules\n" + " run 'git submodule sync' to update it"), ce->name); + -+ free(config_url); + free(gitmodules_url); + } +} -- gitgitgadget