From: Peter Collingbourne Date: Sat, 10 Apr 2010 18:23:49 GMT Subject: [PATCH v2 8/9] git submodule: infrastructure for reading .gitmodules files in arbitrary locations Message-ID: <1270923830-11830-9-git-send-email-peter@pcc.me.uk> In-Reply-To: <1270923830-11830-1-git-send-email-peter@pcc.me.uk> This patch modifies the module_name function in git-submodule.sh to take an optional parameter which specifies the path of the .gitmodules file to read. Signed-off-by: Peter Collingbourne --- git-submodule.sh | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index f1e4e22..75c50b8 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -64,12 +64,18 @@ module_list() # Map submodule path to submodule name # # $1 = path +# $2 = .gitmodules file, default ".gitmodules" # module_name() { + modfile="$2" + if test -z "$modfile" + then + modfile=".gitmodules" + fi # Do we have "submodule..path = $1" defined in .gitmodules file? re=$(printf '%s\n' "$1" | sed -e 's/[].[^$\\*]/\\&/g') - name=$( git config -f .gitmodules --get-regexp '^submodule\..*\.path$' | + name=$( git config -f "$modfile" --get-regexp '^submodule\..*\.path$' | sed -n -e 's|^submodule\.\(.*\)\.path '"$re"'$|\1|p' ) test -z "$name" && die "No submodule mapping found in .gitmodules for path '$path'" -- 1.6.5