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

[PATCH] git-submodule - register module url if adding in place

From
Mark Levedahl <mlevedahl@gmail.com>
Date
Jul 8, 2008, 02:37 UTC
Message-ID
<1215484630-3784-1-git-send-email-mlevedahl@gmail.com>

When adding a new submodule in place, meaning the user created the submodule as a git repo in the tree first, we don't go through git submodule init to register the module. Thus, the url is not stored in .git/config, and no git operation will ever do so. In this case, assume the url the user supplies to git add is the one that should be registered, and do so.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
---
 git-submodule.sh |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index 099a7d7..7525922 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -173,6 +173,16 @@ cmd_add()
 		else
 			die "'$path' already exists and is not a valid git repo"
 		fi
+
+		case "$repo" in
+		./*|../*)
+			url=$(resolve_relative_url "$repo") || exit
+		    ;;
+		*)
+			url="$repo"
+			;;
+		esac
+		git config submodule."$path".url "$url"
 	else
 		case "$repo" in
 		./*|../*)
-- 
1.5.6.2.271.g73ad8
Next: Johannes Schindelin
Message 1 of 4 in “git-submodule - register module url if adding in place”
  1. git-submodule - register module url if adding in placeMark Levedahl, Jul 8, 2008
  2. Johannes SchindelinJul 8, 2008
  3. Mark LevedahlJul 8, 2008
  4. Johannes SchindelinJul 9, 2008

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.