Daniel P. Berrange | aef45d5 | 2017-09-29 11:11:56 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # This code is licensed under the GPL version 2 or later. See |
| 4 | # the COPYING file in the top-level directory. |
| 5 | |
| 6 | set -e |
| 7 | |
| 8 | substat=".git-submodule-status" |
| 9 | |
| 10 | command=$1 |
| 11 | shift |
| 12 | modules="$@" |
| 13 | |
| 14 | if test -z "$modules" |
| 15 | then |
| 16 | test -e $substat || touch $substat |
| 17 | exit 0 |
| 18 | fi |
| 19 | |
| 20 | if ! test -e ".git" |
| 21 | then |
| 22 | echo "$0: unexpectedly called with submodules but no git checkout exists" |
| 23 | exit 1 |
| 24 | fi |
| 25 | |
| 26 | case "$command" in |
| 27 | status) |
| 28 | test -f "$substat" || exit 1 |
| 29 | trap "rm -f ${substat}.tmp" EXIT |
| 30 | git submodule status $modules > "${substat}.tmp" |
| 31 | diff "${substat}" "${substat}.tmp" >/dev/null |
| 32 | exit $? |
| 33 | ;; |
| 34 | update) |
Daniel P. Berrange | 8172bdb | 2017-10-20 14:07:48 +0100 | [diff] [blame] | 35 | git submodule update --init $modules 1>/dev/null |
Daniel P. Berrange | aef45d5 | 2017-09-29 11:11:56 +0100 | [diff] [blame] | 36 | git submodule status $modules > "${substat}" |
| 37 | ;; |
| 38 | esac |