Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-xgit-submodule.sh73
1 files changed, 28 insertions, 45 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index 24914963ca..8b5ad59bde 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -42,6 +42,7 @@ prefix=
custom_name=
depth=
progress=
+dissociate=
die_if_unmatched ()
{
@@ -117,6 +118,9 @@ cmd_add()
-q|--quiet)
GIT_QUIET=1
;;
+ --progress)
+ progress=1
+ ;;
--reference)
case "$2" in '') usage ;; esac
reference_path=$2
@@ -125,6 +129,9 @@ cmd_add()
--reference=*)
reference_path="${1#--reference=}"
;;
+ --dissociate)
+ dissociate=1
+ ;;
--name)
case "$2" in '') usage ;; esac
custom_name=$2
@@ -229,6 +236,11 @@ Use -f if you really want to add it." >&2
sm_name="$sm_path"
fi
+ if ! git submodule--helper check-name "$sm_name"
+ then
+ die "$(eval_gettext "'$sm_name' is not a valid submodule name")"
+ fi
+
# perhaps the path exists and is already a git repo, else clone it
if test -e "$sm_path"
then
@@ -255,7 +267,7 @@ or you are unsure what this means choose another name with the '--name' option."
eval_gettextln "Reactivating local git directory for submodule '\$sm_name'."
fi
fi
- git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix "$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" ${reference:+"$reference"} ${depth:+"$depth"} || exit
+ git submodule--helper clone ${GIT_QUIET:+--quiet} ${progress:+"--progress"} --prefix "$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" ${reference:+"$reference"} ${dissociate:+"--dissociate"} ${depth:+"$depth"} || exit
(
sanitize_submodule_env
cd "$sm_path" &&
@@ -323,45 +335,7 @@ cmd_foreach()
shift
done
- toplevel=$(pwd)
-
- # dup stdin so that it can be restored when running the external
- # command in the subshell (and a recursive call to this function)
- exec 3<&0
-
- {
- git submodule--helper list --prefix "$wt_prefix" ||
- echo "#unmatched" $?
- } |
- while read -r mode sha1 stage sm_path
- do
- die_if_unmatched "$mode" "$sha1"
- if test -e "$sm_path"/.git
- then
- displaypath=$(git submodule--helper relative-path "$prefix$sm_path" "$wt_prefix")
- say "$(eval_gettext "Entering '\$displaypath'")"
- name=$(git submodule--helper name "$sm_path")
- (
- prefix="$prefix$sm_path/"
- sanitize_submodule_env
- cd "$sm_path" &&
- sm_path=$(git submodule--helper relative-path "$sm_path" "$wt_prefix") &&
- # we make $path available to scripts ...
- path=$sm_path &&
- if test $# -eq 1
- then
- eval "$1"
- else
- "$@"
- fi &&
- if test -n "$recursive"
- then
- cmd_foreach "--recursive" "$@"
- fi
- ) <&3 3<&- ||
- die "$(eval_gettext "Stopping at '\$displaypath'; script returned non-zero status.")"
- fi
- done
+ git ${wt_prefix:+-C "$wt_prefix"} ${prefix:+--super-prefix "$prefix"} submodule--helper foreach ${GIT_QUIET:+--quiet} ${recursive:+--recursive} "$@"
}
#
@@ -465,7 +439,7 @@ cmd_update()
GIT_QUIET=1
;;
--progress)
- progress="--progress"
+ progress=1
;;
-i|--init)
init=1
@@ -490,6 +464,9 @@ cmd_update()
--reference=*)
reference="$1"
;;
+ --dissociate)
+ dissociate=1
+ ;;
-m|--merge)
update="merge"
;;
@@ -542,14 +519,15 @@ cmd_update()
{
git submodule--helper update-clone ${GIT_QUIET:+--quiet} \
- ${progress:+"$progress"} \
+ ${progress:+"--progress"} \
${wt_prefix:+--prefix "$wt_prefix"} \
${prefix:+--recursive-prefix "$prefix"} \
${update:+--update "$update"} \
${reference:+"$reference"} \
+ ${dissociate:+"--dissociate"} \
${depth:+--depth "$depth"} \
- ${recommend_shallow:+"$recommend_shallow"} \
- ${jobs:+$jobs} \
+ $recommend_shallow \
+ $jobs \
"$@" || echo "#unmatched" $?
} | {
err=
@@ -599,6 +577,11 @@ cmd_update()
die "$(eval_gettext "Unable to find current \${remote_name}/\${branch} revision in submodule path '\$sm_path'")"
fi
+ if ! $(git config -f "$(git rev-parse --git-common-dir)/modules/$name/config" core.worktree) 2>/dev/null
+ then
+ git submodule--helper connect-gitdir-workingtree "$name" "$sm_path"
+ fi
+
if test "$subsha1" != "$sha1" || test -n "$force"
then
subforce=$force
@@ -614,7 +597,7 @@ cmd_update()
# is not reachable from a ref.
is_tip_reachable "$sm_path" "$sha1" ||
fetch_in_submodule "$sm_path" $depth ||
- die "$(eval_gettext "Unable to fetch in submodule path '\$displaypath'")"
+ say "$(eval_gettext "Unable to fetch in submodule path '\$displaypath'")"
# Now we tried the usual fetch, but $sha1 may
# not be reachable from any of the refs