submodule sync: Update "submodule.<name>.url" for empty directories
If a submodule directory has not been filled by "git submodule update" yet, then "git submodule sync" must still update the super-project's configuration for submodule.<name>.url. This situation occurs when switching between branches with a module from different urls and other branches without the submodule. Signed-off-by: Andreas Köhler <andi5.py@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Andreas Köhler committed
Oct 8, 2010 at 03:07 UTC
33f072f8910081b12780197a2a5423227e437af8
2 files changed
+14
-3
git-submodule.sh
+3
-2
@@ -836,11 +836,12 @@ cmd_sync()
836
;;
837
esac
838
839
+ say "Synchronizing submodule url for '$name'"
840
+ git config submodule."$name".url "$url"
841
+
842
if test -e "$path"/.git
843
then
844
(
842
- say "Synchronizing submodule url for '$name'"
843
- git config submodule."$name".url "$url"
845
clear_local_git_env
846
cd "$path"
847
remote=$(get_default_remote)
t/t7403-submodule-sync.sh
+11
-1
@@ -23,7 +23,9 @@ test_expect_success setup '
23
git commit -m "submodule"
24
) &&
25
git clone super super-clone &&
26
- (cd super-clone && git submodule update --init)
26
+ (cd super-clone && git submodule update --init) &&
27
+ git clone super empty-clone &&
28
+ (cd empty-clone && git submodule init)
29
'
30
31
test_expect_success 'change submodule' '
@@ -64,4 +66,12 @@ test_expect_success '"git submodule sync" should update submodule URLs' '
66
)
67
'
68
69
+test_expect_success '"git submodule sync" should update submodule URLs if not yet cloned' '
70
+ (cd empty-clone &&
71
+ git pull &&
72
+ git submodule sync &&
73
+ test -d "$(git config submodule.submodule.url)"
74
+ )
75
+'
76
+
77
test_done