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

Re: submodule init problem

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 25, 2007, 22:20 UTC
Message-ID
<7v8x94dt2b.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20070725081508.GN1591MdfPADPa@greensroom.kotnet.org>
Sven Verdoolaege <skimo@kotnet.org> writes:
Show 6 quoted lines
> On Tue, Jul 24, 2007 at 06:49:26PM -0700, Junio C Hamano wrote:
>> Ok, this appears it most likely to be related to the fact that
>> one is a prefix of the other in problematic case.
>
> Yes, this has been noted before and Chris Larson sent in a patch,
> but he didn't follow up on it.

Ok, I re-read the thread and came up with a different solution. How does this look?

-- >8 -- git-submodule module_name: avoid using unwieldy "value_regexp" feature.

"module_name $path" function wants to look up a configuration variable "submodule.<modulename>.path" whose value is $path, and return the <modulename> found. "git-config --get-regexp" is the natural thing to use for this, but (1) its value matching has an unfortunate "feature" that takes leading '!' specially, and (2) its output needs to be parsed with sed to extract <modulename> part anyway.

This changes the call to "git-config --get-regexp" not to use the value-regexp part, and moves the "pick the one whose value is $path" part to the downstream sed.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-submodule.sh |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index 1f0cb99..afbaec7 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -46,8 +46,11 @@ get_repo_base() {
 #
 module_name()
 {
-       name=$(GIT_CONFIG=.gitmodules git config --get-regexp '^submodule\..*\.path$' "$1" |
-       sed -nre 's/^submodule\.(.+)\.path .+$/\1/p')
+	# Do we have "submodule.<something>.path = $1" defined in .gitmodules file?
+	re=$(printf '%s' "$1" | sed -e 's/\([^a-zA-Z0-9_]\)/\\\1/g')
+	name=$( GIT_CONFIG=.gitmodules \
+		git config --get-regexp '^submodule\..*\.path$' |
+		sed -n -e 's|^submodule\.\(.*\)\.path '"$re"'$|\1|p' )
        test -z "$name" &&
        die "No submodule mapping found in .gitmodules for path '$path'"
        echo "$name"
Previous: Johannes SchindelinNext: Ricky Nite
Message 26 of 31 in “Let .git/config specify the url for submodules”
  1. Let .git/config specify the url for submodulesLars Hjemli, May 28, 2007
  2. Lars HjemliMay 31, 2007
  3. Junio C HamanoMay 31, 2007
  4. Josef WeidendorferJun 1, 2007
  5. Lars HjemliJun 1, 2007
  6. Sven VerdoolaegeJun 1, 2007
  7. Lars HjemliJun 1, 2007
  8. Sven VerdoolaegeJun 1, 2007
  9. Lars HjemliJun 1, 2007
  10. Sven VerdoolaegeJun 1, 2007
  11. Lars HjemliJun 1, 2007
  12. Linus TorvaldsJun 1, 2007
  13. Junio C HamanoJun 1, 2007
  14. Lars HjemliJun 2, 2007
  15. Sven VerdoolaegeJun 2, 2007
  16. Lars HjemliJun 2, 2007
  17. Junio C HamanoJun 2, 2007
  18. Lars HjemliJun 2, 2007
  19. Junio C HamanoJun 2, 2007
  20. Lars HjemliJun 2, 2007
  21. Sven VerdoolaegeJul 25, 2007
  22. Lars HjemliJul 25, 2007
  23. Johannes SchindelinJul 25, 2007
  24. Lars HjemliJul 25, 2007
  25. Johannes SchindelinJul 25, 2007
  26. Junio C HamanoJul 25, 2007
  27. Ricky NiteJul 25, 2007
  28. Junio C HamanoJul 25, 2007
  29. Sven VerdoolaegeJun 2, 2007
  30. Linus TorvaldsJun 2, 2007
  31. Sven VerdoolaegeJun 2, 2007

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.