]> git.proxmox.com Git - mirror_qemu.git/blob - scripts/git-submodule.sh
Merge remote-tracking branch 'remotes/kraxel/tags/input-20171023-pull-request' into...
[mirror_qemu.git] / scripts / git-submodule.sh
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)
35 git submodule update --init $modules 1>/dev/null
36 git submodule status $modules > "${substat}"
37 ;;
38 esac