-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit_pull_recursive.sh
executable file
·36 lines (29 loc) · 1.14 KB
/
git_pull_recursive.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# Copyright (c) 2018 Grzegorz Stepien
#
# This file and its contents are provided under the BSD 3-clause license.
# For more details, see './LICENSE.md'
# (where '.' represents this program's root directory).
# Pull root project, pull already cloned submodules
# (recusively, i.e. including submodules of those submodules and so on)
# and clone missing submodules (again, recursively).
# Always pulls the version of each submodule associated with its superproject
# (which is not necessarily the newest one).
# Submodules are pulled with detached HEAD.
# Helper method for error printing
error_msg()
{
TITLE="Unsuccessful execution of this script via: \"$0 $CONSOLE_PARAMS\""
"$PRINTF" "ERROR: $TITLE\n\tMessage: $1\n"
}
CONSOLE_PARAMS=$@
# Check tool availability
GIT=$(which git)
PRINTF=$(which printf)
if [ -z "$GIT" -o -z "$PRINTF" ]; then
error_msg "At least one required tool is missing. See \"Check tool availability\" paragraph of \"$0\" for more details."
exit 1
fi
"$GIT" fetch && "$GIT" fetch --tags && "$GIT" merge FETCH_HEAD &&
"$GIT" submodule update --init --recursive &&
"$GIT" submodule update --recursive