blob: 08932a35f0b2f47df6535a735e61578e060ea1db [file] [log] [blame]
Daniel P. Berrangeaef45d52017-09-29 11:11:56 +01001#!/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
6set -e
7
8substat=".git-submodule-status"
9
10command=$1
11shift
12modules="$@"
13
14if test -z "$modules"
15then
16 test -e $substat || touch $substat
17 exit 0
18fi
19
20if ! test -e ".git"
21then
22 echo "$0: unexpectedly called with submodules but no git checkout exists"
23 exit 1
24fi
25
26case "$command" in
27status)
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 ;;
34update)
Daniel P. Berrange8172bdb2017-10-20 14:07:48 +010035 git submodule update --init $modules 1>/dev/null
Daniel P. Berrangeaef45d52017-09-29 11:11:56 +010036 git submodule status $modules > "${substat}"
37 ;;
38esac