]> asedeno.scripts.mit.edu Git - git.git/blobdiff - git-submodule.sh
add_file_to_index: skip rehashing if the cached stat already matches
[git.git] / git-submodule.sh
index 0ba016135f205513e81e62723fc71c97091b0b85..2cfeaddbc27fd00e089bcf2ffd76e1271f1f3eb9 100755 (executable)
@@ -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"
@@ -233,8 +236,7 @@ modules_list()
                        say "-$sha1 $path"
                        continue;
                fi
-               revname=$(unset GIT_DIR && cd "$path" && git describe --tags $sha1)
-               set_name_rev "$path" $"sha1"
+               set_name_rev "$path" "$sha1"
                if git diff-files --quiet -- "$path"
                then
                        say " $sha1 $path$revname"
@@ -242,7 +244,7 @@ modules_list()
                        if test -z "$cached"
                        then
                                sha1=$(unset GIT_DIR && cd "$path" && git rev-parse --verify HEAD)
-                               set_name_rev "$path" $"sha1"
+                               set_name_rev "$path" "$sha1"
                        fi
                        say "+$sha1 $path$revname"
                fi