blob: d8fbc7e47e0c64a802ae7871fa18e81a6e458b9f [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)
35 git submodule update --init $modules 1>/dev/null 2>&1
36 git submodule status $modules > "${substat}"
37 ;;
38esac