From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Cc: Patrick Steinhardt <ps@pks.im>,
Jens Lehmann <Jens.Lehmann@web.de>,
Heiko Voigt <hvoigt@hvoigt.net>
Subject: [RFC/PATCH 1/4] submodules: implement synchronizing of remotes.
Date: Wed, 8 Apr 2015 12:58:22 +0200 [thread overview]
Message-ID: <1428490705-11586-2-git-send-email-ps@pks.im> (raw)
In-Reply-To: <1428490705-11586-1-git-send-email-ps@pks.im>
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
next prev parent reply other threads:[~2015-04-08 11:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-08 10:58 [RFC/PATCH 0/4] submodule remotes Patrick Steinhardt
2015-04-08 10:58 ` Patrick Steinhardt [this message]
2015-04-08 15:46 ` [RFC/PATCH 1/4] submodules: implement synchronizing of remotes Junio C Hamano
2015-04-09 11:57 ` Patrick Steinhardt
2015-04-08 10:58 ` [RFC/PATCH 2/4] submodules: implement remote commands Patrick Steinhardt
2015-04-08 10:58 ` [RFC/PATCH 3/4] submodules: update docs to reflect remotes Patrick Steinhardt
2015-04-08 10:58 ` [RFC/PATCH 4/4] submodules: add bash completion for remotes Patrick Steinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1428490705-11586-2-git-send-email-ps@pks.im \
--to=ps@pks.im \
--cc=Jens.Lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=hvoigt@hvoigt.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).