Thread (7 messages) 7 messages, 2 authors, 2016-06-15

[RFC/PATCH 1/4] submodules: implement synchronizing of remotes.

DORMANTno replies

From: Patrick Steinhardt <hidden>
Date: 2016-06-15 23:04:24
Subsystem: the rest · Maintainer: Linus Torvalds

Previously it was not possible to specify custom remotes for
submodules. This feature has now been implemented and can be
accessed by setting the keys 'submodule-remote.$name.$remote.url'
and 'submodule-remote.$name.$remote.push-url', respectively.

When issuing a `git submodule sync` we will test if submodules
have one or more remotes specified and if so those will be either
added if nonexistent or their URLs will be adjusted to match the
specified URLs.
---
 git-submodule.sh | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
diff --git a/git-submodule.sh b/git-submodule.sh
index 36797c3..599a847 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -1268,6 +1268,7 @@ cmd_status()
 		fi
 	done
 }
+
 #
 # Sync remote urls for submodules
 # This makes the value for remote.$remote.url match the value
@@ -1347,6 +1348,32 @@ cmd_sync()
 			)
 			fi
 		fi
+
+		git config -f .gitmodules --get-regexp "submodule-remote\.$name\..*\.url" 2>/dev/null |
+		while read key url
+		do
+			remote=$(echo "$key" | sed "s/submodule-remote\.$name\.\(.*\)\.url/\1/")
+			pushurl=$(git config -f .gitmodules --get "submodule-remote.$name.$remote.pushurl")
+
+			(
+				cd "$sm_path"
+
+				if ! git remote | grep "^$remote$" >/dev/null 2>/dev/null
+				then
+					say "$(eval_gettext "Adding remote '$remote' for submodule '$prefix$sm_path'")"
+					git remote add "$remote" "$url"
+				else
+					say "$(eval_gettext "Setting URL for remote '$remote' in submodule '$prefix$sm_path'")"
+					git remote set-url "$remote" "$url"
+				fi
+
+				if test ! -z "$pushurl"
+				then
+					say "$(eval_gettext "Setting push URL for remote '$remote' in submodule '$prefix$sm_path'")"
+					git remote set-url --push "$remote" "$pushurl"
+				fi
+			)
+		done
 	done
 }
 
-- 
2.3.5
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help