aboutsummaryrefslogtreecommitdiff
path: root/git-submodule.sh
diff options
context:
space:
mode:
authorW. Trevor King <wking@tremily.us>2012-12-11 13:58:15 -0500
committerJunio C Hamano <gitster@pobox.com>2012-12-11 21:46:49 -0800
commit88ce00c378f709937c74a97037aa2692b883d683 (patch)
treecd386d890880620a39cb74d963e17dfa6823de3e /git-submodule.sh
parentb7973fbbc3f8f72df352f4ef1a2ff325db92c36f (diff)
downloadgit-88ce00c378f709937c74a97037aa2692b883d683.tar.gz
git-88ce00c378f709937c74a97037aa2692b883d683.tar.xz
submodule: add get_submodule_config helper funtion
Several submodule configuration variables (e.g. fetchRecurseSubmodules) are read from .gitmodules with local overrides from the usual git config files. This shell function mimics that logic to help initialize configuration variables in git-submodule.sh. Signed-off-by: W. Trevor King <wking@tremily.us> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-xgit-submodule.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index 2365149d0..263a60c4f 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -153,6 +153,32 @@ die_if_unmatched ()
}
#
+# Print a submodule configuration setting
+#
+# $1 = submodule name
+# $2 = option name
+# $3 = default value
+#
+# Checks in the usual git-config places first (for overrides),
+# otherwise it falls back on .gitmodules. This allows you to
+# distribute project-wide defaults in .gitmodules, while still
+# customizing individual repositories if necessary. If the option is
+# not in .gitmodules either, print a default value.
+#
+get_submodule_config () {
+ name="$1"
+ option="$2"
+ default="$3"
+ value=$(git config submodule."$name"."$option")
+ if test -z "$value"
+ then
+ value=$(git config -f .gitmodules submodule."$name"."$option")
+ fi
+ printf '%s' "${value:-$default}"
+}
+
+
+#
# Map submodule path to submodule name
#
# $1 = path