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>
Junio C Hamano committed
Jul 25, 2007 at 15:51 UTC
537601ac74db2d93665b20a67ba05851703bb2c3
1 file changed
+5
-2
git-submodule.sh
+5
-2
@@ -46,8 +46,11 @@ get_repo_base() {
46
#
47
module_name()
48
{
49
- name=$(GIT_CONFIG=.gitmodules git config --get-regexp '^submodule\..*\.path$' "$1" |
50
- sed -nre 's/^submodule\.(.+)\.path .+$/\1/p')
49
+ # Do we have "submodule.<something>.path = $1" defined in .gitmodules file?
50
+ re=$(printf '%s' "$1" | sed -e 's/\([^a-zA-Z0-9_]\)/\\\1/g')
51
+ name=$( GIT_CONFIG=.gitmodules \
52
+ git config --get-regexp '^submodule\..*\.path$' |
53
+ sed -n -e 's|^submodule\.\(.*\)\.path '"$re"'$|\1|p' )
54
test -z "$name" &&
55
die "No submodule mapping found in .gitmodules for path '$path'"
56
echo "$name"