add ssh option

This commit is contained in:
Adrian 2024-08-14 16:06:54 +02:00
parent 90935aa635
commit 53a04a7821

View File

@ -15,6 +15,7 @@ OPTIONS
-H allows the $HOME directory to be used by git_update.sh. By default, git_update.sh cannot access $HOME to prevent default behavior.
If you need the global .gitconfig located in your $HOME to be used, you should supply the -H option.
-a specifies that the aggressive option of the git garbage collection must be used. Only advised when changes happen in many different objects. Will slow down the execution.
-o ssh options for ssh clone
DESCRIPTION
This script will replace the destination with the wanted commit of a git repository. The history is not preserved but tags are. Untracked files remain.
The git commands have been chosen so as to minimize the memory and bandwidth usages."
@ -26,8 +27,9 @@ ref=main
dst='.'
use_home=false
be_aggressive="false"
ssh_opts="ssh"
while getopts ":hr:d:H" option; do
while getopts ":ho:r:d:H" option; do
case $option in
h) # display Help
Help
@ -40,6 +42,8 @@ while getopts ":hr:d:H" option; do
use_home="true";;
a) #use -a in git gc call
be_aggressive="true";;
o) # ssh options
ssh_opts="$ssh_opts $OPTARG";;
\?) # invalid option
echo "Error: Invalid option here"
exit;;
@ -76,6 +80,6 @@ if [ -d .git ] ; then
else
echo "cloning..."
clone_dst='.'
git clone -b "$ref" --recurse-submodules --shallow-submodules --depth 1 "$repo" "$clone_dst"
git clone -b "$ref" --recurse-submodules --shallow-submodules --depth 1 --config core.sshCommand="$ssh_opts" "$repo" "$clone_dst"
fi