From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.178 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796159347; b=4DcQdJc+eeANLNhKzF2MJiNEFjIbeGf4fEN+xlhfDVmf9sNldzkA/ljHGTYk91ZGZhTA NgVQioC/0oPcH3Bz6ELvtXKwziB5LkVUKKTkEWkWXVderdRIrFBzdM1gdEs74LmSuiPHn VlcGGFmjTFx69RWf8x7rEzxjsIjsZbRKj0U0eMaWh78QatVOBq2jAPYCYIWrJ/4Cp4WQu 0JxC1fgngpAiBocKLxnzN3Rk6Q1hPlDF+/BclVC2ae4CPBKhwhfNihB4/637kMU1BIVKu srOhGlWtEax0vOH+V/8QRGGZIe1TXIupq6U0S2TXg+3fq4BI7VrO4PqsQjS611huHJw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796159347; 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=Ig9ixeOay2afAx9mKPcsoLUjBWz/fI9E4RZQ0i5BMKQ=; b=yQv1PlXneGWJEODixB5vUmx4zEGyqsNa/XV+bF/HR/1h4GK0NVEBkAmL5K4ItvdDfh+G vGgasPuktrpSm2nMjyuOV9epTARSvopPpCe0zffwpU/syruoBHXmNJkWgrrVamj0ffA1V /F1YjlCEg//JSsDF0kJjaDuwtWppFFu2ZMjSN3NjHmbQQotkAY/CqzHveB0cb3vTki51C PTaEYI1fBK52rKQbZwwwbkCqMgMcTLo/BbJ7vAqU1xTfylZ4lxiQk9fZ68fzBI5dywPI5 GTNOL/bstXOsVecVvxXszEY+7uyGJCHNte02NcaCL+TIwcbpz2tpOOqPUy4S0Oy7h8Q== 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=iz9CFSBh; arc=none smtp.remote-ip=209.85.210.178 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 82E1B606A329 for ; Tue, 1 Dec 2026 21:09:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 82E1B606A329 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=iz9CFSBh Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-8a4c72951b8so7741565b3a.3 for ; Tue, 01 Dec 2026 13:09:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796159347; x=1796764147; 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=Ig9ixeOay2afAx9mKPcsoLUjBWz/fI9E4RZQ0i5BMKQ=; b=iz9CFSBh7Vz7NxQUAle1uofXYN9Zank4Sv6oiVcQqoW+9WbPaGaoAbPSdcaQhngEub s67GpS6uhZw31EicjxtquNNda8c3TkQcUlq38iDmkytKxuO1OCUfKmsvkrh2kKIAr5bM g0y9sQxJ7b6o33vc5ojoL/I5DpVHfSWxWyUYDWZVQNfjZZWAzGEMTE+YxHXPJ73oNjA5 QT0GxWz7FUtSJle/BQG1MA+5xCZL4Vfnop7JxCBDFuuLjgI+ePX7I6qtjrXlPa9m1aUk vldWTnBovtk/uzzUEiTTp/44LGKJGNavg4hSA5kf49vwj8nSHazzWUiUE6gGVr13uFyk 9y9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796159347; x=1796764147; 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=Ig9ixeOay2afAx9mKPcsoLUjBWz/fI9E4RZQ0i5BMKQ=; b=fDe7asNfGARjo11vONCyguEONJ0e3Sz4GhlNbp6rEE5iG3lH4/jZjL0MP7Tjlwj3ow SedMcJeBSy/1TJA5O738kRXOUegGuYkJU7thTsK/R7BiIyXrjp9OAzcCs0B3MIqh+f+E Zn3mwW3etG1NRl6bnwuQXFmbE7qbtjWqLYCgcjFvQyn/ESPzvb5kimV/Q4YgEBLJJcG4 bDXcx3MYTUG8kOzXipN788kT5M04/TszThz8BXj5uwicOJwOgF/m9dzpVdskHun016LY 8/PPNSlldjqOCeRLoS1PAQhTbfbhdyFcA/YQaHuvSSqYFIJxgBnVO6tgTr1bj2n9AzLl dNPg== X-Gm-Message-State: APuU4Z8AxhD+nRv9n1rgmQQNJqJv37P3SDYVn5ozkQrX+ryGrsIJZ5U/ gAhiKZ1g7+ohcAAqlthO0FX+ZSHzsNtmfVNI+0JJdvyHlUh0JbTOWIyjGkZUmA== X-Gm-Gg: AZFdTZdYoJHZn7tmFHyCSQL0DbykanPC0kDYYLQPJWhe5m4sJGswV/Z0Nxdus7WOVr7 DV0ygPWnuMpzMmcpFsjLXd7omonM9rFj8CODL4rh9BEv+4/JLDeyx8F73m6Pfqr+sv+v20r6OAm MadvtO+qvG6eihO3GB2HQW+jjliRNzJvNHCUCs1EFjpqR7Nv4AfV27KdL8XQvuB1mqnLLGo6b0b 35NJmUfA++r1uOpLR21q1DT+NyhHNHwf0PhRSF4f5E81H32OI/5NfDI0n51sl4nw6KugLQU1fTQ 8KiXSLm0b5BJdEJ02Kp9bJqWgFoCDxIG8G5vLhjDTDNShEaSXbG1NdIJYxYAzTRain/gU7oDX5q oO12zaKyvlXVneDEafKTGDgseBxgwnvtl61DG0FNizHPe3J/fwkOS6qb/dattTWuMzqGiUwsiJY OY/GdjzWoDimYS7KHTwVcistA9b3t/yI7cm6+/PUesRbUPt3Hwl3rYRIw2ew4vJDwR8lNi8UEYU /+bFw3C0ICWwYeR/JbamGGymINIhXG8G2klqxe/DPNNMNImIgQaOasSmq+wGB58FX8KFeLS5XG8 ZeL+tT2W1Opngsq5Mtqm3Kq44onBN2ZLSEYxtBsK7G3wThKvyeUEbF80o70SkU/5EMFYgxj8HPe /As1Z72E= X-Received: by 2002:a05:6300:670e:b0:400:7003:55c7 with SMTP id adf61e73a8af0-4014bc549a7mr42554877637.29.1796159346526; Tue, 01 Dec 2026 13:09:06 -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 d2e1a72fcca58-8c87344184fsm20915846b3a.35.2026.12.01.13.09.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 13:09:05 -0800 (PST) Message-Id: In-Reply-To: References: From: "Alessio Attilio via GitGitGadget" Date: Tue, 01 Dec 2026 21:08:58 +0000 Subject: [PATCH v5 4/4] status: test submodule URL warnings 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 Exercise the warning and sync advice across output formats, relative URLs, pathspecs, ignored submodules, populated remotes, and commit status. Document when the warning appears and how to clear the mismatch. Signed-off-by: Alessio Attilio --- Documentation/git-status.adoc | 12 ++++ t/t7508-status.sh | 121 ++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+) diff --git a/Documentation/git-status.adoc b/Documentation/git-status.adoc index 9acca52bfb..6e997fbef0 100644 --- a/Documentation/git-status.adoc +++ b/Documentation/git-status.adoc @@ -22,6 +22,18 @@ are what you _would_ commit by running `git commit`; the second and third are what you _could_ commit by running `git add` before running `git commit`. +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. 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 ------- diff --git a/t/t7508-status.sh b/t/t7508-status.sh index e10c961268..ff03c6a96e 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -921,6 +921,127 @@ test_expect_success 'setup status submodule summary' ' git add sm ' +test_expect_success 'status reports submodule URL mismatch' ' + test_when_finished "rm -rf url-test" && + test_create_repo url-test/source && + test_commit -C url-test/source initial && + test_create_repo url-test/super && + git -C url-test/super -c protocol.file.allow=always \ + submodule add "$PWD/url-test/source" module && + git -C url-test/super commit -m "add submodule" && + git -C url-test/super status >url-test/actual 2>url-test/err && + test_must_be_empty url-test/err && + git -C url-test/super config -f .gitmodules submodule.module.url \ + "$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 && + test_must_be_empty url-test/err && + git -C url-test/super status -- module >url-test/actual 2>url-test/err && + test_grep "module.*different URL" url-test/err && + git -C url-test/super status >url-test/actual 2>url-test/err && + test_grep "module.*different URL" url-test/err && + test_grep "git submodule sync" url-test/err && + git -C url-test/super submodule sync && + git -C url-test/super status >url-test/actual 2>url-test/err && + test_must_be_empty url-test/err && + git -C url-test/super remote add origin ../source-parent && + git -C url-test/super config -f .gitmodules submodule.module.url \ + ../relative-source && + git -C url-test/super status >url-test/actual 2>url-test/err && + test_grep "module.*different URL" url-test/err && + git -C url-test/super submodule sync && + git -C url-test/super status >url-test/actual 2>url-test/err && + test_must_be_empty url-test/err && + git -C url-test/super config -f .gitmodules submodule.module.url \ + ../another-relative-source && + git -C url-test/super status >url-test/actual 2>url-test/err && + test_grep "module.*different URL" url-test/err && + git -C url-test/super submodule sync && + git -C url-test/super status >url-test/actual 2>url-test/err && + test_must_be_empty url-test/err && + git -C url-test/super/module config remote.origin.url \ + "$PWD/url-test/fork" && + git -C url-test/super config -f .gitmodules submodule.module.url \ + ../fork-source && + git -C url-test/super status >url-test/actual 2>url-test/err && + test_must_be_empty url-test/err && + git -C url-test/super config -f .gitmodules submodule.module.url \ + "$PWD/url-test/upstream-source" && + git -C url-test/super submodule sync && + git -C url-test/super/module config remote.upstream.url \ + "$PWD/url-test/upstream-source" && + git -C url-test/super/module config remote.origin.url \ + "$PWD/url-test/fork" && + git -C url-test/super config submodule.module.url \ + "$PWD/url-test/stale-source" && + git -C url-test/super status >url-test/actual 2>url-test/err && + test_grep "module.*different URL" url-test/err && + git -C url-test/super/module config --add remote.origin.url \ + "$PWD/url-test/another-fork" && + git -C url-test/super config -f .gitmodules submodule.module.url \ + ../another-fork-source && + git -C url-test/super status >url-test/actual 2>url-test/err && + test_must_be_empty url-test/err && + git -C url-test/super/module config --unset-all remote.origin.url && + git -C url-test/super config --add submodule.module.url \ + "$PWD/url-test/another-configured-source" && + git -C url-test/super status >url-test/actual 2>url-test/err && + test_grep "module.*different URL" url-test/err +' + +test_expect_success 'status compares relative submodule URLs only once' ' + test_when_finished "rm -rf url-test" && + test_create_repo url-test/relative-source && + test_commit -C url-test/relative-source initial && + test_create_repo url-test/relative-super && + git -C url-test/relative-super -c protocol.file.allow=always \ + submodule add "$PWD/url-test/relative-source" module && + git -C url-test/relative-super commit -m "add submodule" && + git -C url-test/relative-super remote add origin ../a/b && + git -C url-test/relative-super config -f .gitmodules \ + submodule.module.url ../mod1 && + git -C url-test/relative-super submodule sync && + git -C url-test/relative-super status >url-test/actual 2>url-test/err && + test_must_be_empty url-test/err && + git -C url-test/relative-super config -f .gitmodules \ + submodule.module.url ../mod2 && + git -C url-test/relative-super status >url-test/actual 2>url-test/err && + test_grep "module.*different URL" url-test/err && + git -C url-test/relative-super remote set-url origin a/b && + git -C url-test/relative-super config -f .gitmodules \ + submodule.module.url ../mod1 && + git -C url-test/relative-super submodule sync && + git -C url-test/relative-super status >url-test/actual 2>url-test/err && + test_must_be_empty url-test/err && + git -C url-test/relative-super config -f .gitmodules \ + submodule.module.url ../mod2 && + git -C url-test/relative-super status >url-test/actual 2>url-test/err && + test_grep "module.*different URL" url-test/err +' + test_expect_success 'status submodule summary is disabled by default' ' cat >expect <