{"thread":{"id":"25388","subject":"[PATCH] submodule sync: Update \"submodule.<name>.url\" for empty directories","startedAt":"2010-10-08T01:07:48Z","lastAt":"2010-10-08T01:07:48Z","messageCount":1,"participants":["Andreas Köhler"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"152942","messageId":"1286500068-31345-1-git-send-email-andi5.py@gmx.net","threadId":"25388","inReplyTo":null,"subject":"[PATCH] submodule sync: Update \"submodule.<name>.url\" for empty directories","fromName":"Andreas Köhler","fromEmail":"andi5.py@gmx.net","sentAt":"2010-10-08T01:07:48Z","receivedAt":"2010-10-08T01:07:48Z","isPatch":true,"sender":{"key":"andi5.py@gmx.net","avatar":null},"body":"If a submodule directory has not been filled by \"git submodule update\"\nyet, then \"git submodule sync\" must still update the super-project's\nconfiguration for submodule.<name>.url.\n\nThis situation occurs when switching between branches with a module from\ndifferent urls and other branches without the submodule.\n\nSigned-off-by: Andreas Köhler <andi5.py@gmx.net>\n---\n git-submodule.sh          |    5 +++--\n t/t7403-submodule-sync.sh |   12 +++++++++++-\n 2 files changed, 14 insertions(+), 3 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 9ebbab7..c291eed 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -836,11 +836,12 @@ cmd_sync()\n \t\t\t;;\n \t\tesac\n \n+\t\tsay \"Synchronizing submodule url for '$name'\"\n+\t\tgit config submodule.\"$name\".url \"$url\"\n+\n \t\tif test -e \"$path\"/.git\n \t\tthen\n \t\t(\n-\t\t\tsay \"Synchronizing submodule url for '$name'\"\n-\t\t\tgit config submodule.\"$name\".url \"$url\"\n \t\t\tclear_local_git_env\n \t\t\tcd \"$path\"\n \t\t\tremote=$(get_default_remote)\ndiff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh\nindex 02522f9..e5b1953 100755\n--- a/t/t7403-submodule-sync.sh\n+++ b/t/t7403-submodule-sync.sh\n@@ -23,7 +23,9 @@ test_expect_success setup '\n \t git commit -m \"submodule\"\n \t) &&\n \tgit clone super super-clone &&\n-\t(cd super-clone && git submodule update --init)\n+\t(cd super-clone && git submodule update --init) &&\n+\tgit clone super empty-clone &&\n+\t(cd empty-clone && git submodule init)\n '\n \n test_expect_success 'change submodule' '\n@@ -64,4 +66,12 @@ test_expect_success '\"git submodule sync\" should update submodule URLs' '\n \t)\n '\n \n+test_expect_success '\"git submodule sync\" should update submodule URLs if not yet cloned' '\n+\t(cd empty-clone &&\n+\t git pull &&\n+\t git submodule sync &&\n+\t test -d \"$(git config submodule.submodule.url)\"\n+\t)\n+'\n+\n test_done\n-- \n1.7.0.4\n"}]}