192
n=$(($1 + 0)) 2>/dev/null && test "$n" = "$1"
193
}
194
195
+# Sanitize the local git environment for use within a submodule. We
196
+# can't simply use clear_local_git_env since we want to preserve some
197
+# of the settings from GIT_CONFIG_PARAMETERS.
198
+sanitize_submodule_env()
199
+{
200
+ sanitized_config=$(git submodule--helper sanitize-config)
201
+ clear_local_git_env
202
+ GIT_CONFIG_PARAMETERS=$sanitized_config
203
+}
204
+
205
#
206
# Add a new submodule to the working tree, .gitmodules and the index
207
#
359
fi
360
git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix "$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" ${reference:+"$reference"} ${depth:+"$depth"} || exit
361
(
352
- clear_local_git_env
362
+ sanitize_submodule_env
363
cd "$sm_path" &&
364
# ash fails to wordsplit ${branch:+-b "$branch"...}
365
case "$branch" in
428
name=$(git submodule--helper name "$sm_path")
429
(
430
prefix="$prefix$sm_path/"
421
- clear_local_git_env
431
+ sanitize_submodule_env
432
cd "$sm_path" &&
433
sm_path=$(relative_path "$sm_path") &&
434
# we make $path available to scripts ...
723
cloned_modules="$cloned_modules;$name"
724
subsha1=
725
else
716
- subsha1=$(clear_local_git_env; cd "$sm_path" &&
726
+ subsha1=$(sanitize_submodule_env; cd "$sm_path" &&
727
git rev-parse --verify HEAD) ||
728
die "$(eval_gettext "Unable to find current revision in submodule path '\$displaypath'")"
729
fi
733
if test -z "$nofetch"
734
then
735
# Fetch remote before determining tracking $sha1
726
- (clear_local_git_env; cd "$sm_path" && git-fetch) ||
736
+ (sanitize_submodule_env; cd "$sm_path" && git-fetch) ||
737
die "$(eval_gettext "Unable to fetch in submodule path '\$sm_path'")"
738
fi
729
- remote_name=$(clear_local_git_env; cd "$sm_path" && get_default_remote)
730
- sha1=$(clear_local_git_env; cd "$sm_path" &&
739
+ remote_name=$(sanitize_submodule_env; cd "$sm_path" && get_default_remote)
740
+ sha1=$(sanitize_submodule_env; cd "$sm_path" &&
741
git rev-parse --verify "${remote_name}/${branch}") ||
742
die "$(eval_gettext "Unable to find current ${remote_name}/${branch} revision in submodule path '\$sm_path'")"
743
fi
755
then
756
# Run fetch only if $sha1 isn't present or it
757
# is not reachable from a ref.
748
- (clear_local_git_env; cd "$sm_path" &&
758
+ (sanitize_submodule_env; cd "$sm_path" &&
759
( (rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) &&
760
test -z "$rev") || git-fetch)) ||
761
die "$(eval_gettext "Unable to fetch in submodule path '\$displaypath'")"
797
die "$(eval_gettext "Invalid update mode '$update_module' for submodule '$name'")"
798
esac
799
790
- if (clear_local_git_env; cd "$sm_path" && $command "$sha1")
800
+ if (sanitize_submodule_env; cd "$sm_path" && $command "$sha1")
801
then
802
say "$say_msg"
803
elif test -n "$must_die_on_failure"
813
then
814
(
815
prefix="$prefix$sm_path/"
806
- clear_local_git_env
816
+ sanitize_submodule_env
817
cd "$sm_path" &&
818
eval cmd_update
819
)
851
852
set_name_rev () {
853
revname=$( (
844
- clear_local_git_env
854
+ sanitize_submodule_env
855
cd "$1" && {
856
git describe "$2" 2>/dev/null ||
857
git describe --tags "$2" 2>/dev/null ||
1135
else
1136
if test -z "$cached"
1137
then
1128
- sha1=$(clear_local_git_env; cd "$sm_path" && git rev-parse --verify HEAD)
1138
+ sha1=$(sanitize_submodule_env; cd "$sm_path" && git rev-parse --verify HEAD)
1139
fi
1140
set_name_rev "$sm_path" "$sha1"
1141
say "+$sha1 $displaypath$revname"
1145
then
1146
(
1147
prefix="$displaypath/"
1138
- clear_local_git_env
1148
+ sanitize_submodule_env
1149
cd "$sm_path" &&
1150
eval cmd_status
1151
) ||
1219
if test -e "$sm_path"/.git
1220
then
1221
(
1212
- clear_local_git_env
1222
+ sanitize_submodule_env
1223
cd "$sm_path"
1224
remote=$(get_default_remote)
1225
git config remote."$remote".url "$sub_origin_url"