dotfiles/.local/bin/scripts/git-get

19 lines
643 B
Text
Raw Normal View History

#!/bin/sh -ex
# Clones from resolving the arguments and switches into the new directory
# 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"
case $# in
(1) dir=$(basename ${remote%.git});;
2022-07-03 22:33:28 +02:00
(3) test "$3" != "$(git config --get user.name)" &&
prefix=$(echo "$3" | sed "s|\(.\)\b.*$|\1|") &&
case "$2" in
("$prefix"*) ;;
("$(git config --get user.name)") ;;
(*) dir="${prefix}_$2";;
esac;;
esac
2022-07-05 11:40:11 +02:00
shift $(expr $# \& $# \< 3 \| 3)
git clone $remote "$@" $dir --recurse-submodules
cd "${dir:-${4:-$2}}"