Sven Verdoolaege <skimo@xxxxxxxxxx> writes: > 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@xxxxxxxxx> --- 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" - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html