From d4612d94aeb0e40042169e9beb2b60a04bdebb00 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 30 Nov 2012 11:52:36 -0500 Subject: [PATCH] submodule: add get_submodule_config helper funtion --- git-submodule.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/git-submodule.sh b/git-submodule.sh index ab6b1107b..97ce5e408 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -151,6 +151,33 @@ die_if_unmatched () fi } +# +# 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 # -- 2.26.2