From: Junio C Hamano Date: Wed, 25 Jul 2007 22:51:26 +0000 (-0700) Subject: git-submodule module_name: avoid using unwieldy "value_regexp" feature. X-Git-Tag: v1.5.3-rc4~65 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/537601ac74db2d93665b20a67ba05851703bb2c3?ds=inline;hp=--cc git-submodule module_name: avoid using unwieldy "value_regexp" feature. "module_name $path" function wants to look up a configuration variable "submodule..path" whose value is $path, and return the 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 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 --- 537601ac74db2d93665b20a67ba05851703bb2c3 diff --git a/git-submodule.sh b/git-submodule.sh index 1f0cb99dcb..afbaec7a74 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..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"