@@ -250,7 +250,6 @@ Use -f if you really want to add it." &&
250
250
url=" $repo "
251
251
;;
252
252
esac
253
- git config submodule." $path " .url " $url "
254
253
else
255
254
256
255
module_clone " $path " " $realrepo " " $reference " || exit
@@ -264,6 +263,7 @@ Use -f if you really want to add it." &&
264
263
esac
265
264
) || die " $( eval_gettext " Unable to checkout submodule '\$ path'" ) "
266
265
fi
266
+ git config submodule." $path " .url " $url "
267
267
268
268
git add $force " $path " ||
269
269
die " $( eval_gettext " Failed to add submodule '\$ path'" ) "
@@ -363,25 +363,26 @@ cmd_init()
363
363
do
364
364
# Skip already registered paths
365
365
name=$( module_name " $path " ) || exit
366
- url=$( git config submodule." $name " .url)
367
- test -z " $url " || continue
368
-
369
- url=$( git config -f .gitmodules submodule." $name " .url)
370
- test -z " $url " &&
371
- die " $( eval_gettext " No url found for submodule path '\$ path' in .gitmodules" ) "
372
-
373
- # Possibly a url relative to parent
374
- case " $url " in
375
- ./* |../* )
376
- url=$( resolve_relative_url " $url " ) || exit
377
- ;;
378
- esac
379
-
380
- git config submodule." $name " .url " $url " ||
381
- die " $( eval_gettext " Failed to register url for submodule path '\$ path'" ) "
366
+ if test -z " $( git config " submodule.$name .url" ) "
367
+ then
368
+ url=$( git config -f .gitmodules submodule." $name " .url)
369
+ test -z " $url " &&
370
+ die " $( eval_gettext " No url found for submodule path '\$ path' in .gitmodules" ) "
371
+
372
+ # Possibly a url relative to parent
373
+ case " $url " in
374
+ ./* |../* )
375
+ url=$( resolve_relative_url " $url " ) || exit
376
+ ;;
377
+ esac
378
+ git config submodule." $name " .url " $url " ||
379
+ die " $( eval_gettext " Failed to register url for submodule path '\$ path'" ) "
380
+ fi
382
381
382
+ # Copy "update" setting when it is not set yet
383
383
upd=" $( git config -f .gitmodules submodule." $name " .update) "
384
384
test -z " $upd " ||
385
+ test -n " $( git config submodule." $name " .update) " ||
385
386
git config submodule." $name " .update " $upd " ||
386
387
die " $( eval_gettext " Failed to register update mode for submodule path '\$ path'" ) "
387
388
@@ -925,17 +926,20 @@ cmd_sync()
925
926
;;
926
927
esac
927
928
928
- say " $( eval_gettext " Synchronizing submodule url for '\$ name'" ) "
929
- git config submodule." $name " .url " $url "
930
-
931
- if test -e " $path " /.git
929
+ if git config " submodule.$name .url" > /dev/null 2> /dev/null
932
930
then
933
- (
934
- clear_local_git_env
935
- cd " $path "
936
- remote=$( get_default_remote)
937
- git config remote." $remote " .url " $url "
938
- )
931
+ say " $( eval_gettext " Synchronizing submodule url for '\$ name'" ) "
932
+ git config submodule." $name " .url " $url "
933
+
934
+ if test -e " $path " /.git
935
+ then
936
+ (
937
+ clear_local_git_env
938
+ cd " $path "
939
+ remote=$( get_default_remote)
940
+ git config remote." $remote " .url " $url "
941
+ )
942
+ fi
939
943
fi
940
944
done
941
945
}
0 commit comments