Skip to contentSkip to conversation

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

PATCH In review David Aguilar 2 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 git-submodule.sh          |    3 ++-
 t/t7403-submodule-sync.sh |    3 +++
 2 files changed, 5 insertions(+), 1 deletions(-)
git-submodule.sh +2 -1
index 170186f..be7e478 100755
@@ -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
t/t7403-submodule-sync.sh +3 -0
index 7538756..3033c4a 100755
@@ -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)"
 	)
 '
 
Signature · 1 line
1.7.2.1.97.g3235b.dirty
#1 lore raw

Am 8/18/2010 12:01, schrieb David Aguilar:

git-submodule.sh cmd_sync() · line 844

Quoted 6 lines
git-submodule.sh +2 -0
@@ -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?

git-submodule.sh cmd_sync() · line 848

Quoted 5 lines
git-submodule.sh +0 -1
 			cd "$path"
 			remote=$(get_default_remote)
-			say "Synchronizing submodule url for '$name'"
 			git config remote."$remote".url "$url"
 		)

-- Hannes

#2 lore raw

PATCH v2 1/1 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.

---

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(-)
git-submodule.sh +2 -1
index 170186f..9ebbab7 100755
@@ -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
t/t7403-submodule-sync.sh +3 -0
index 7538756..3033c4a 100755
@@ -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)"
 	)
 '
 
Signature · 1 line
1.7.2.1.97.g3235b
#3 lore raw
In reply to Johannes Sixt
Quoted 10 lines · Johannes Sixt

Am 8/18/2010 12:01, schrieb David Aguilar:

git-submodule.sh cmd_sync() · line 844

Quoted 6 lines
git-submodule.sh +2 -0
@@ -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.

Quoted 8 lines

git-submodule.sh cmd_sync() · line 848

Quoted 6 lines
git-submodule.sh +0 -1
 			cd "$path"
 			remote=$(get_default_remote)
-			say "Synchronizing submodule url for '$name'"
 			git config remote."$remote".url "$url"
 		)

-- Hannes

Signature · 1 line
	David