threads / patch / 24779

patchsubmodule sync: Update "submodule.<name>.url"

Subject: [PATCH] submodule sync: Update "submodule.<name>.url"

## tl;dr

4 messages between Aug 18, 2010 and Aug 18, 2010. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

David Aguilar· Aug 18, 2010, 10:01 UTC · lore

When "git submodule sync" synchronizes the repository URLs it only updates submodules' .git/config. However, the old URLs still exist in the super-project's .git/config.

Update the super-project's configuration so that commands such as "git submodule update" use the URLs from .gitmodules.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
 git-submodule.sh          |    3 ++-
 t/t7403-submodule-sync.sh |    3 +++
 2 files changed, 5 insertions(+), 1 deletions(-)
Show changes to 2 files +5 −1

git-submodule.sh, t/t7403-submodule-sync.sh

diff --git a/git-submodule.sh b/git-submodule.sh
index 170186f..be7e478 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -840,9 +840,10 @@ cmd_sync()
 		then
 		(
 			clear_local_git_env
+			say "Synchronizing submodule url for '$name'"
+			git config submodule."$name".url "$url"
 			cd "$path"
 			remote=$(get_default_remote)
-			say "Synchronizing submodule url for '$name'"
 			git config remote."$remote".url "$url"
 		)
 		fi
diff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh
index 7538756..3033c4a 100755
--- a/t/t7403-submodule-sync.sh
+++ b/t/t7403-submodule-sync.sh
@@ -58,6 +58,9 @@ test_expect_success '"git submodule sync" should update submodule URLs' '
 	(cd super-clone/submodule &&
 	 git checkout master &&
 	 git pull
+	) &&
+	(cd super-clone &&
+	 test -d "$(git config submodule.submodule.url)"
 	)
 '
 
-- 
1.7.2.1.97.g3235b.dirty
Johannes Sixt· Aug 18, 2010, 10:45 UTC · re: David Aguilar · lore

Re: [PATCH] submodule sync: Update "submodule.<name>.url"

Am 8/18/2010 12:01, schrieb David Aguilar:
Show 6 quoted lines
> @@ -840,9 +840,10 @@ cmd_sync()
>  		then
>  		(
>  			clear_local_git_env
> +			say "Synchronizing submodule url for '$name'"
> +			git config submodule."$name".url "$url"

This git config applies to the super module, right? As such, shouldn't it happen before you clear_local_git_env?

Show 5 quoted lines
>  			cd "$path"
>  			remote=$(get_default_remote)
> -			say "Synchronizing submodule url for '$name'"
>  			git config remote."$remote".url "$url"
>  		)
-- Hannes
David Aguilar· Aug 18, 2010, 15:46 UTC · re: Johannes Sixt · lore

Re: [PATCH] submodule sync: Update "submodule.<name>.url"

On Wed, Aug 18, 2010 at 12:45:54PM +0200, Johannes Sixt wrote:
Show 10 quoted lines
> Am 8/18/2010 12:01, schrieb David Aguilar:
> > @@ -840,9 +840,10 @@ cmd_sync()
> >  		then
> >  		(
> >  			clear_local_git_env
> > +			say "Synchronizing submodule url for '$name'"
> > +			git config submodule."$name".url "$url"
> 
> This git config applies to the super module, right? As such, shouldn't it
> happen before you clear_local_git_env?
Good catch, thanks.  I'll resend.
Show 8 quoted lines
> 
> >  			cd "$path"
> >  			remote=$(get_default_remote)
> > -			say "Synchronizing submodule url for '$name'"
> >  			git config remote."$remote".url "$url"
> >  		)
> 
> -- Hannes
-- 
	David
David Aguilar· Aug 18, 2010, 15:58 UTC · re: Johannes Sixt · lore

[PATCH v2] submodule sync: Update "submodule.<name>.url"

When "git submodule sync" synchronizes the repository URLs it only updates submodules' .git/config. However, the old URLs still exist in the super-project's .git/config.

Update the super-project's configuration so that commands such as "git submodule update" use the URLs from .gitmodules.

Signed-off-by: David Aguilar <davvid@gmail.com>
---

Changes since v1: We now call clear_local_git_env after configuring the super project (thanks Johannes).

 git-submodule.sh          |    3 ++-
 t/t7403-submodule-sync.sh |    3 +++
 2 files changed, 5 insertions(+), 1 deletions(-)
Show changes to 2 files +5 −1

git-submodule.sh, t/t7403-submodule-sync.sh

diff --git a/git-submodule.sh b/git-submodule.sh
index 170186f..9ebbab7 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -839,10 +839,11 @@ cmd_sync()
 		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)
-			say "Synchronizing submodule url for '$name'"
 			git config remote."$remote".url "$url"
 		)
 		fi
diff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh
index 7538756..3033c4a 100755
--- a/t/t7403-submodule-sync.sh
+++ b/t/t7403-submodule-sync.sh
@@ -58,6 +58,9 @@ test_expect_success '"git submodule sync" should update submodule URLs' '
 	(cd super-clone/submodule &&
 	 git checkout master &&
 	 git pull
+	) &&
+	(cd super-clone &&
+	 test -d "$(git config submodule.submodule.url)"
 	)
 '
 
-- 
1.7.2.1.97.g3235b

← back to recent threads