Code

Merge branch 'jl/submodule-add-relurl-wo-upstream'
[git.git] / git-submodule.sh
index 3daa0c834cad1ed402376adf535c73e1c06172e4..bc1d3fa663a5eb39dd96f6ad2ca17437073ceb0a 100755 (executable)
@@ -35,7 +35,7 @@ resolve_relative_url ()
 {
        remote=$(get_default_remote)
        remoteurl=$(git config "remote.$remote.url") ||
-               die "$(eval_gettext "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=/
@@ -242,14 +242,6 @@ Use -f if you really want to add it." &&
                        die "$(eval_gettext "'\$path' already exists and is not a valid git repo")"
                fi
 
-               case "$repo" in
-               ./*|../*)
-                       url=$(resolve_relative_url "$repo") || exit
-                   ;;
-               *)
-                       url="$repo"
-                       ;;
-               esac
        else
 
                module_clone "$path" "$realrepo" "$reference" || exit
@@ -263,7 +255,7 @@ Use -f if you really want to add it." &&
                        esac
                ) || die "$(eval_gettext "Unable to checkout submodule '\$path'")"
        fi
-       git config submodule."$path".url "$url"
+       git config submodule."$path".url "$realrepo"
 
        git add $force "$path" ||
        die "$(eval_gettext "Failed to add submodule '\$path'")"