submodule add: clean up duplicated code
[gitweb.git] / git-submodule.sh
index 4361ae418cfc032f793d14af057e2b178922ca1f..32cb05443a851e7bd77d86b3bb3b2f7962c4d53b 100755 (executable)
@@ -34,7 +34,7 @@ resolve_relative_url ()
 {
        remote=$(get_default_remote)
        remoteurl=$(git config "remote.$remote.url") ||
-               die "remote ($remote) does not have a url defined in .git/config"
+               remoteurl=$(pwd) # the repository is its own authoritative upstream
        url="$1"
        remoteurl=${remoteurl%/}
        sep=/
@@ -238,15 +238,7 @@ cmd_add()
                        die "'$path' already exists and is not a valid git repo"
                fi
 
-               case "$repo" in
-               ./*|../*)
-                       url=$(resolve_relative_url "$repo") || exit
-                   ;;
-               *)
-                       url="$repo"
-                       ;;
-               esac
-               git config submodule."$path".url "$url"
+               git config submodule."$path".url "$realrepo"
        else
 
                module_clone "$path" "$realrepo" "$reference" || exit