diff options
Diffstat (limited to 'scripts/git-submodule.sh')
-rwxr-xr-x | scripts/git-submodule.sh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/git-submodule.sh b/scripts/git-submodule.sh new file mode 100755 index 0000000000..d8fbc7e47e --- /dev/null +++ b/scripts/git-submodule.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# +# This code is licensed under the GPL version 2 or later. See +# the COPYING file in the top-level directory. + +set -e + +substat=".git-submodule-status" + +command=$1 +shift +modules="$@" + +if test -z "$modules" +then + test -e $substat || touch $substat + exit 0 +fi + +if ! test -e ".git" +then + echo "$0: unexpectedly called with submodules but no git checkout exists" + exit 1 +fi + +case "$command" in +status) + test -f "$substat" || exit 1 + trap "rm -f ${substat}.tmp" EXIT + git submodule status $modules > "${substat}.tmp" + diff "${substat}" "${substat}.tmp" >/dev/null + exit $? + ;; +update) + git submodule update --init $modules 1>/dev/null 2>&1 + git submodule status $modules > "${substat}" + ;; +esac |