From 33f072f8910081b12780197a2a5423227e437af8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andreas=20K=C3=B6hler?= Date: Fri, 8 Oct 2010 03:07:48 +0200 Subject: [PATCH] submodule sync: Update "submodule..url" for empty directories MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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..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 Signed-off-by: Junio C Hamano --- git-submodule.sh | 5 +++-- t/t7403-submodule-sync.sh | 12 +++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index 9ebbab798..c291eed59 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -836,11 +836,12 @@ cmd_sync() ;; esac + say "Synchronizing submodule url for '$name'" + git config submodule."$name".url "$url" + if test -e "$path"/.git then ( - say "Synchronizing submodule url for '$name'" - git config submodule."$name".url "$url" clear_local_git_env cd "$path" remote=$(get_default_remote) diff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh index 02522f962..e5b19538b 100755 --- a/t/t7403-submodule-sync.sh +++ b/t/t7403-submodule-sync.sh @@ -23,7 +23,9 @@ test_expect_success setup ' git commit -m "submodule" ) && git clone super super-clone && - (cd super-clone && git submodule update --init) + (cd super-clone && git submodule update --init) && + git clone super empty-clone && + (cd empty-clone && git submodule init) ' test_expect_success 'change submodule' ' @@ -64,4 +66,12 @@ test_expect_success '"git submodule sync" should update submodule URLs' ' ) ' +test_expect_success '"git submodule sync" should update submodule URLs if not yet cloned' ' + (cd empty-clone && + git pull && + git submodule sync && + test -d "$(git config submodule.submodule.url)" + ) +' + test_done -- 2.26.2