Tim Landscheidt <tim@xxxxxxxxxxxxxxxxxx> writes: > It's trivial to fix this for trivial repository specifiers. > But for specifiers with white space, quote or shell meta > characters, my mind boggles :-). Something like this. As always, totally untested. git-submodule.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index 9bb2e13..f9991cb 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -30,6 +30,10 @@ nofetch= update= prefix= +sq () { + git rev-parse --sq-quote "$@" +} + # Resolve relative url by appending to parent's url resolve_relative_url () { @@ -121,7 +125,7 @@ module_clone() { path=$1 url=$2 - reference="$3" + references=$3 quiet= if test -n "$GIT_QUIET" then @@ -163,13 +167,11 @@ module_clone() echo "gitdir: $rel_gitdir" >"$path/.git" rm -f "$gitdir/index" else - mkdir -p "$gitdir_base" - if test -n "$reference" - then - git-clone $quiet "$reference" -n "$url" "$path" --separate-git-dir "$gitdir" - else - git-clone $quiet -n "$url" "$path" --separate-git-dir "$gitdir" - fi || + mkdir -p "$gitdir_base" && + cmd='git clone $quiet '"$references" && + cmd="$cmd "' -n "$url" "$path" --separate-git-dir "$gitdir"' && + # echo "$cmd" && # if you want to debug this + eval "$cmd" || die "$(eval_gettext "Clone of '\$url' into submodule path '\$path' failed")" fi } @@ -200,11 +202,11 @@ cmd_add() ;; --reference) case "$2" in '') usage ;; esac - reference="--reference=$2" + reference="$reference --reference=$(sq "$2") " shift ;; --reference=*) - reference="$1" + reference="$reference$(sq "$1") " shift ;; --) @@ -450,12 +452,12 @@ cmd_update() ;; --reference) case "$2" in '') usage ;; esac - reference="--reference=$2" - orig_flags="$orig_flags $(git rev-parse --sq-quote "$1")" + reference="$reference --reference=$(sq "$2") " + orig_flags="$orig_flags $(sq "$1")" shift ;; --reference=*) - reference="$1" + reference="$reference$(sq "$1") " ;; -m|--merge) update="merge" @@ -523,7 +525,7 @@ Maybe you want to use 'update --init'?")" if ! test -d "$path"/.git -o -f "$path"/.git then - module_clone "$path" "$url" "$reference"|| exit + module_clone "$path" "$url" "$reference" || exit cloned_modules="$cloned_modules;$name" subsha1= else -- 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