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

[PATCH] git-submodule.sh: Always initialize $url variable

From
NNNicolas Viennot and Sid Nair <nicolas@viennot.com>
Date
May 28, 2012, 09:41 UTC
Message-ID
<1338198114-20480-1-git-send-email-nviennot+sidnair@viennot.biz>

When git submodule init was called, the $url variable was not initialized properly for submodules which have already been initialized. This led to two problems.

First, when all of the submodules were initialized, each showed an empty url instead of the actual url.

Second, when previously initialized submodules were printed after newly added submodules, the displayed urls were incorrect.

Cc: Jens Lehmann <Jens.Lehmann@web.de>
Cc: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Nicolas Viennot <nicolas@viennot.biz>
Signed-off-by: Sid Nair <sidnair09@gmail.com>
---
 git-submodule.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index 64a70d6..92fd6e2 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -396,11 +396,11 @@ cmd_init()
 	module_list "$@" |
 	while read mode sha1 stage sm_path
 	do
-		# Skip already registered paths
 		name=$(module_name "$sm_path") || exit
+		url=$(git config -f .gitmodules submodule."$name".url)
+		# Skip already registered paths
 		if test -z "$(git config "submodule.$name.url")"
 		then
-			url=$(git config -f .gitmodules submodule."$name".url)
 			test -z "$url" &&
 			die "$(eval_gettext "No url found for submodule path '\$sm_path' in .gitmodules")"
 
-- 
1.7.8.6
Next: Jens Lehmann
Message 1 of 2 in “git-submodule.sh: Always initialize $url variable”
  1. git-submodule.sh: Always initialize $url variableNicolas Viennot and Sid Nair, May 28, 2012
  2. submodules: print "registered for path" message only onceJens Lehmann, May 28, 2012

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.