Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-12-11 00:11:42 +0300
committerJunio C Hamano <gitster@pobox.com>2019-12-11 00:11:42 +0300
commit99c4ff1bdabc2122a7c6a2b8df87acdd0c2dd18f (patch)
treeef438c96a3f3f35644fefabf47a14fa10cea907e /git-submodule.sh
parent55d607d85b4c22fe2091102ed1eb907ea29b956a (diff)
parent26b061007c1259ed4692554994961dd26874e63e (diff)
Merge branch 'dl/submodule-set-url'
"git submodule" learned a subcommand "set-url". * dl/submodule-set-url: submodule: teach set-url subcommand
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-xgit-submodule.sh52
1 files changed, 51 insertions, 1 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index 58713c5467..aaa1809d24 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -12,6 +12,7 @@ USAGE="[--quiet] [--cached]
or: $dashless [--quiet] deinit [-f|--force] (--all| [--] <path>...)
or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--[no-]recommend-shallow] [--reference <repository>] [--recursive] [--] [<path>...]
or: $dashless [--quiet] set-branch (--default|--branch <branch>) [--] <path>
+ or: $dashless [--quiet] set-url [--] <path> <newurl>
or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
or: $dashless [--quiet] foreach [--recursive] <command>
or: $dashless [--quiet] sync [--recursive] [--] [<path>...]
@@ -767,6 +768,55 @@ cmd_set_branch() {
}
#
+# Configures a submodule's remote url
+#
+# $@ = requested path, requested url
+#
+cmd_set_url() {
+ while test $# -ne 0
+ do
+ case "$1" in
+ -q|--quiet)
+ GIT_QUIET=1
+ ;;
+ --)
+ shift
+ break
+ ;;
+ -*)
+ usage
+ ;;
+ *)
+ break
+ ;;
+ esac
+ shift
+ done
+
+ if test $# -ne 2
+ then
+ usage
+ fi
+
+ # we can't use `git submodule--helper name` here because internally, it
+ # hashes the path so a trailing slash could lead to an unintentional no match
+ name="$(git submodule--helper list "$1" | cut -f2)"
+ if test -z "$name"
+ then
+ exit 1
+ fi
+
+ url="$2"
+ if test -z "$url"
+ then
+ exit 1
+ fi
+
+ git submodule--helper config submodule."$name".url "$url"
+ git submodule--helper sync ${GIT_QUIET:+--quiet} "$name"
+}
+
+#
# Show commit summary for submodules in index or working tree
#
# If '--cached' is given, show summary between index and given commit,
@@ -1065,7 +1115,7 @@ cmd_absorbgitdirs()
while test $# != 0 && test -z "$command"
do
case "$1" in
- add | foreach | init | deinit | update | set-branch | status | summary | sync | absorbgitdirs)
+ add | foreach | init | deinit | update | set-branch | set-url | status | summary | sync | absorbgitdirs)
command=$1
;;
-q|--quiet)