forked from kollerma/git-submodule-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-rclone
executable file
·46 lines (40 loc) · 1.03 KB
/
git-rclone
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
37
38
39
40
41
42
43
44
45
46
#!/bin/bash -e
## Recursive clone
## clone into $2 directory
## and attach heads.
## read input, display help if necessary
if [[ "$@" == "" || "$@" == *--help* ]]; then
cat<<EOF
Recursive clone
This command executes a recursive clone, i.e., the repository
is cloned as well as all submodules. The submodules HEADs are
attached, if possible. See also "git clone --help".
Usage:
git rclone <repository> [<directory>]
EOF
exit 0;
fi
if [[ "$2" ]]; then
name="$2"
else
name=`basename "$1"`
name=${name%.git}
fi
## from the git mailinglist:
function git
{
LC_MESSAGES=C command git "$@"
}
export git
echo "Cloning into $name..."
git clone --recursive -q "$1" "$name" > /dev/null
echo "done."
cd "$name"
## attach heads
if [ -f .gitmodules ]; then
echo "Attaching heads of submodules..."
#git submodule --quiet foreach --recursive git attach-head -w
git submodule --quiet foreach --recursive 'echo "$toplevel/$path"' |
xargs -r -n1 -P5 bash -c 'cd "$1"; git attach-head -w' xargs
echo "done."
fi