2022-08-21 12:29:51 +02:00
|
|
|
#!/bin/sh -e
|
2021-06-18 17:51:57 +02:00
|
|
|
# Clones from resolving the arguments and switches into the new directory
|
2022-08-21 12:29:51 +02:00
|
|
|
# ARGS: see git-repo, all arguments beyond the first three are forwarded to git clone
|
2021-06-19 21:24:14 +02:00
|
|
|
remote=$(git-repo "$@")
|
|
|
|
echo "Cloning $remote"
|
2022-08-04 23:53:53 +02:00
|
|
|
test $1 = https && shift
|
2022-06-27 21:50:29 +02:00
|
|
|
case $# in
|
|
|
|
(1) dir=$(basename ${remote%.git});;
|
2022-11-09 18:52:27 +01:00
|
|
|
(3) # TODO recognize shared prefix
|
|
|
|
test "$3" != "$(git config --get user.name)" &&
|
2022-07-03 22:33:28 +02:00
|
|
|
prefix=$(echo "$3" | sed "s|\(.\)\b.*$|\1|") &&
|
|
|
|
case "$2" in
|
|
|
|
("$prefix"*) ;;
|
|
|
|
("$(git config --get user.name)") ;;
|
|
|
|
(*) dir="${prefix}_$2";;
|
|
|
|
esac;;
|
2022-06-27 21:50:29 +02:00
|
|
|
esac
|
2022-08-21 12:29:51 +02:00
|
|
|
case "$4" in (-*|"") cdir="$2";; (*) cdir="$4";; esac
|
|
|
|
shift $(expr 3 \& $# \> 3 \| $#)
|
2022-06-27 21:50:29 +02:00
|
|
|
git clone $remote "$@" $dir --recurse-submodules
|
2022-08-21 12:29:51 +02:00
|
|
|
cd "${dir:-$cdir}"
|
2022-07-06 09:17:45 +01:00
|
|
|
exec
|