path=$1
url=$2
reference="$3"
+ quiet=
+ if test -n "$GIT_QUIET"
+ then
+ quiet=-q
+ fi
+
gitdir=
gitdir_base=
- name=$(module_name "$path")
+ name=$(module_name "$path" 2>/dev/null)
base_path=$(dirname "$path")
gitdir=$(git rev-parse --git-dir)
mkdir -p "$gitdir_base"
if test -n "$reference"
then
- git-clone "$reference" -n "$url" "$path" --separate-git-dir "$gitdir"
+ git-clone $quiet "$reference" -n "$url" "$path" --separate-git-dir "$gitdir"
else
- git-clone -n "$url" "$path" --separate-git-dir "$gitdir"
+ git-clone $quiet -n "$url" "$path" --separate-git-dir "$gitdir"
fi ||
die "$(eval_gettext "Clone of '\$url' into submodule path '\$path' failed")"
fi
if test -z "$force" && ! git add --dry-run --ignore-missing "$path" > /dev/null 2>&1
then
- (
- eval_gettext "The following path is ignored by one of your .gitignore files:
+ eval_gettextln "The following path is ignored by one of your .gitignore files:
\$path
-Use -f if you really want to add it." &&
- echo
- ) >&2
+Use -f if you really want to add it." >&2
exit 1
fi
then
if test -d "$path"/.git -o -f "$path"/.git
then
- eval_gettext "Adding existing repo at '\$path' to the index"; echo
+ eval_gettextln "Adding existing repo at '\$path' to the index"
else
die "$(eval_gettext "'\$path' already exists and is not a valid git repo")"
fi
--recursive)
recursive=1
;;
+ --checkout)
+ update="checkout"
+ ;;
--)
shift
break
fi
name=$(module_name "$path") || exit
url=$(git config submodule."$name".url)
- update_module=$(git config submodule."$name".update)
+ if ! test -z "$update"
+ then
+ update_module=$update
+ else
+ update_module=$(git config submodule."$name".update)
+ fi
+
+ if test "$update_module" = "none"
+ then
+ echo "Skipping submodule '$path'"
+ continue
+ fi
+
if test -z "$url"
then
# Only mention uninitialized submodules when its
die "$(eval_gettext "Unable to find current revision in submodule path '\$path'")"
fi
- if ! test -z "$update"
- then
- update_module=$update
- fi
-
if test "$subsha1" != "$sha1"
then
subforce=$force
;; # removed
*)
# unexpected type
- (
- eval_gettext "unexpected mode \$mod_dst" &&
- echo
- ) >&2
+ eval_gettextln "unexpected mode \$mod_dst" >&2
continue ;;
esac
fi
done |
if test -n "$for_status"; then
if [ -n "$files" ]; then
- gettext "# Submodules changed but not updated:"; echo
+ gettextln "# Submodules changed but not updated:"
else
- gettext "# Submodule changes to be committed:"; echo
+ gettextln "# Submodule changes to be committed:"
fi
echo "#"
sed -e 's|^|# |' -e 's|^# $|#|'