branch="$(git symbolic-ref HEAD 2>/dev/null)"
remote="$(git config branch.${branch#refs/heads/}.remote)"
remote="${remote:-origin}"
- remoteurl="$(git config remote.$remote.url)" ||
- die "remote ($remote) does not have a url in .git/config"
+ remoteurl=$(git config "remote.$remote.url") ||
+ die "remote ($remote) does not have a url defined in .git/config"
url="$1"
while test -n "$url"
do
module_name()
{
# Do we have "submodule.<something>.path = $1" defined in .gitmodules file?
- re=$(printf '%s' "$1" | sed -e 's/[].[^$\\*]/\\&/g')
+ re=$(printf '%s\n' "$1" | sed -e 's/[].[^$\\*]/\\&/g')
name=$( git config -f .gitmodules --get-regexp '^submodule\..*\.path$' |
sed -n -e 's|^submodule\.\(.*\)\.path '"$re"'$|\1|p' )
test -z "$name" &&
# perhaps the path exists and is already a git repo, else clone it
if test -e "$path"
then
- if test -d "$path/.git" &&
- test "$(unset GIT_DIR; cd $path; git rev-parse --git-dir)" = ".git"
+ if test -d "$path"/.git -o -f "$path"/.git
then
echo "Adding existing repo at '$path' to the index"
else
case "$repo" in
./*|../*)
# dereference source url relative to parent's url
- realrepo="$(resolve_relative_url $repo)" ;;
+ realrepo=$(resolve_relative_url "$repo") || exit
+ ;;
*)
# Turn the source into an absolute path if
# it is local
# Possibly a url relative to parent
case "$url" in
./*|../*)
- url="$(resolve_relative_url "$url")"
+ url=$(resolve_relative_url "$url") || exit
;;
esac
do
case "$1" in
-q|--quiet)
+ shift
quiet=1
;;
-i|--init)
break
;;
esac
- shift
done
git ls-files --stage -- "$@" | grep '^160000 ' |