@@ -192,6 +192,17 @@ isnumber()
192
192
n=$(( $1 + 0 )) 2> /dev/null && test " $n " = " $1 "
193
193
}
194
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
+ save_config=$GIT_CONFIG_PARAMETERS
201
+ clear_local_git_env
202
+ GIT_CONFIG_PARAMETERS=$save_config
203
+ export GIT_CONFIG_PARAMETERS
204
+ }
205
+
195
206
#
196
207
# Add a new submodule to the working tree, .gitmodules and the index
197
208
#
@@ -347,9 +358,9 @@ Use -f if you really want to add it." >&2
347
358
echo " $( eval_gettext " Reactivating local git directory for submodule '\$ sm_name'." ) "
348
359
fi
349
360
fi
350
- git submodule--helper clone ${GIT_QUIET: +--quiet} --prefix " $wt_prefix " --path " $sm_path " --name " $sm_name " --url " $realrepo " " $reference " " $depth " || exit
361
+ git submodule--helper clone ${GIT_QUIET: +--quiet} --prefix " $wt_prefix " --path " $sm_path " --name " $sm_name " --url " $realrepo " ${reference : + " $reference " } ${depth : + " $depth " } || exit
351
362
(
352
- clear_local_git_env
363
+ sanitize_submodule_env
353
364
cd " $sm_path " &&
354
365
# ash fails to wordsplit ${branch:+-b "$branch"...}
355
366
case " $branch " in
@@ -418,7 +429,7 @@ cmd_foreach()
418
429
name=$( git submodule--helper name " $sm_path " )
419
430
(
420
431
prefix=" $prefix$sm_path /"
421
- clear_local_git_env
432
+ sanitize_submodule_env
422
433
cd " $sm_path " &&
423
434
sm_path=$( relative_path " $sm_path " ) &&
424
435
# we make $path available to scripts ...
@@ -601,14 +612,14 @@ cmd_deinit()
601
612
}
602
613
603
614
is_tip_reachable () (
604
- clear_local_git_env
615
+ sanitize_submodule_env &&
605
616
cd " $1 " &&
606
617
rev=$( git rev-list -n 1 " $2 " --not --all 2> /dev/null) &&
607
618
test -z " $rev "
608
619
)
609
620
610
621
fetch_in_submodule () (
611
- clear_local_git_env
622
+ sanitize_submodule_env &&
612
623
cd " $1 " &&
613
624
case " $2 " in
614
625
' ' )
@@ -736,11 +747,11 @@ Maybe you want to use 'update --init'?")"
736
747
737
748
if ! test -d " $sm_path " /.git && ! test -f " $sm_path " /.git
738
749
then
739
- git submodule--helper clone ${GIT_QUIET: +--quiet} --prefix " $prefix " --path " $sm_path " --name " $name " --url " $url " " $reference " " $depth " || exit
750
+ git submodule--helper clone ${GIT_QUIET: +--quiet} --prefix " $prefix " --path " $sm_path " --name " $name " --url " $url " ${reference : + " $reference " } ${depth : + " $depth " } || exit
740
751
cloned_modules=" $cloned_modules ;$name "
741
752
subsha1=
742
753
else
743
- subsha1=$( clear_local_git_env ; cd " $sm_path " &&
754
+ subsha1=$( sanitize_submodule_env ; cd " $sm_path " &&
744
755
git rev-parse --verify HEAD) ||
745
756
die " $( eval_gettext " Unable to find current revision in submodule path '\$ displaypath'" ) "
746
757
fi
@@ -750,11 +761,11 @@ Maybe you want to use 'update --init'?")"
750
761
if test -z " $nofetch "
751
762
then
752
763
# Fetch remote before determining tracking $sha1
753
- (clear_local_git_env ; cd " $sm_path " && git-fetch) ||
764
+ (sanitize_submodule_env ; cd " $sm_path " && git-fetch) ||
754
765
die " $( eval_gettext " Unable to fetch in submodule path '\$ sm_path'" ) "
755
766
fi
756
- remote_name=$( clear_local_git_env ; cd " $sm_path " && get_default_remote)
757
- sha1=$( clear_local_git_env ; cd " $sm_path " &&
767
+ remote_name=$( sanitize_submodule_env ; cd " $sm_path " && get_default_remote)
768
+ sha1=$( sanitize_submodule_env ; cd " $sm_path " &&
758
769
git rev-parse --verify " ${remote_name} /${branch} " ) ||
759
770
die " $( eval_gettext " Unable to find current ${remote_name} /${branch} revision in submodule path '\$ sm_path'" ) "
760
771
fi
@@ -819,7 +830,7 @@ Maybe you want to use 'update --init'?")"
819
830
die " $( eval_gettext " Invalid update mode '$update_module ' for submodule '$name '" ) "
820
831
esac
821
832
822
- if (clear_local_git_env ; cd " $sm_path " && $command " $sha1 " )
833
+ if (sanitize_submodule_env ; cd " $sm_path " && $command " $sha1 " )
823
834
then
824
835
say " $say_msg "
825
836
elif test -n " $must_die_on_failure "
@@ -835,7 +846,7 @@ Maybe you want to use 'update --init'?")"
835
846
then
836
847
(
837
848
prefix=" $prefix$sm_path /"
838
- clear_local_git_env
849
+ sanitize_submodule_env
839
850
cd " $sm_path " &&
840
851
eval cmd_update
841
852
)
@@ -873,7 +884,7 @@ Maybe you want to use 'update --init'?")"
873
884
874
885
set_name_rev () {
875
886
revname=$( (
876
- clear_local_git_env
887
+ sanitize_submodule_env
877
888
cd " $1 " && {
878
889
git describe " $2 " 2> /dev/null ||
879
890
git describe --tags " $2 " 2> /dev/null ||
@@ -1157,7 +1168,7 @@ cmd_status()
1157
1168
else
1158
1169
if test -z " $cached "
1159
1170
then
1160
- sha1=$( clear_local_git_env ; cd " $sm_path " && git rev-parse --verify HEAD)
1171
+ sha1=$( sanitize_submodule_env ; cd " $sm_path " && git rev-parse --verify HEAD)
1161
1172
fi
1162
1173
set_name_rev " $sm_path " " $sha1 "
1163
1174
say " +$sha1 $displaypath$revname "
@@ -1167,7 +1178,7 @@ cmd_status()
1167
1178
then
1168
1179
(
1169
1180
prefix=" $displaypath /"
1170
- clear_local_git_env
1181
+ sanitize_submodule_env
1171
1182
wt_prefix=
1172
1183
cd " $sm_path " &&
1173
1184
eval cmd_status
@@ -1242,7 +1253,7 @@ cmd_sync()
1242
1253
if test -e " $sm_path " /.git
1243
1254
then
1244
1255
(
1245
- clear_local_git_env
1256
+ sanitize_submodule_env
1246
1257
cd " $sm_path "
1247
1258
remote=$( get_default_remote)
1248
1259
git config remote." $remote " .url " $sub_origin_url "
0 commit comments