git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Removed the .git/config check from "git submodule status"

From
Peter Collingbourne <peter@pcc.me.uk>
Date
Jan 13, 2010, 20:31 UTC
Message-ID
<1263414699-1613-1-git-send-email-peter@pcc.me.uk>

"git submodule status" requires that the following conditions be met for a submodule to be considered initialised:

1) The existence of an entry in .git/config for that module
2) The existence of a .git subdirectory under the submodule directory

Plumbing only requires condition 2 to be met, and does not care about condition 1 (these entries being part of the git-submodule porcelain). Therefore removing condition 1 from "git submodule status" will make git-submodule's view of the world consistent with plumbing's thus eliminating unexpected behaviour.

Furthermore if the user is using the git-submodule porcelain and not cloning submodules himself, condition 1 should always follow from condition 2 because "git submodule update" requires that the submodule entry in .git/config be present.

By removing condition 1 we can also remove the call to module_name from cmd_status. "git submodule status" will now work if the user is using a submodule porcelain other than git-submodule, because module_name requires that the .gitmodules file be maintained by git-submodule.

Signed-off-by: Peter Collingbourne <peter@pcc.me.uk>
---
 git-submodule.sh           |    4 +---
 t/t7400-submodule-basic.sh |    8 ++------
 2 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index 77d2232..811f001 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -738,10 +738,8 @@ cmd_status()
 	module_list "$@" |
 	while read mode sha1 stage path
 	do
-		name=$(module_name "$path") || exit
-		url=$(git config submodule."$name".url)
 		displaypath="$prefix$path"
-		if test -z "$url" || ! test -d "$path"/.git -o -f "$path"/.git
+		if ! test -d "$path"/.git -o -f "$path"/.git
 		then
 			say "-$sha1 $displaypath"
 			continue;
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 1a4dc5f..c16fb14 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -106,12 +106,8 @@ test_expect_success 'submodule add with ./, /.. and // in path' '
 	)
 '
 
-test_expect_success 'status should fail for unmapped paths' '
-	if git submodule status
-	then
-		echo "[OOPS] submodule status succeeded"
-		false
-	elif ! GIT_CONFIG=.gitmodules git config submodule.example.path init
+test_expect_success 'mapping a path using git config' '
+	if ! GIT_CONFIG=.gitmodules git config submodule.example.path init
 	then
 		echo "[OOPS] git config failed to update .gitmodules"
 		false
-- 
1.6.5
Message 1 of 1 in “Removed the .git/config check from "git submodule status"”
  1. Removed the .git/config check from "git submodule status"Peter Collingbourne, Jan 13, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.