Merge remote-tracking branch 'remotes/kraxel/tags/fixes-20171023-pull-request' into...
[qemu/kevin.git] / scripts / git-submodule.sh
blob08932a35f0b2f47df6535a735e61578e060ea1db
1 #!/bin/sh
3 # This code is licensed under the GPL version 2 or later. See
4 # the COPYING file in the top-level directory.
6 set -e
8 substat=".git-submodule-status"
10 command=$1
11 shift
12 modules="$@"
14 if test -z "$modules"
15 then
16 test -e $substat || touch $substat
17 exit 0
20 if ! test -e ".git"
21 then
22 echo "$0: unexpectedly called with submodules but no git checkout exists"
23 exit 1
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 $?
34 update)
35 git submodule update --init $modules 1>/dev/null
36 git submodule status $modules > "${substat}"
38 esac