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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]