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. -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. 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. -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 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. 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." The git commands have been chosen so as to minimize the memory and bandwidth usages."
@ -26,8 +27,9 @@ ref=main
dst='.' dst='.'
use_home=false use_home=false
be_aggressive="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 case $option in
h) # display Help h) # display Help
Help Help
@ -40,6 +42,8 @@ while getopts ":hr:d:H" option; do
use_home="true";; use_home="true";;
a) #use -a in git gc call a) #use -a in git gc call
be_aggressive="true";; be_aggressive="true";;
o) # ssh options
ssh_opts="$ssh_opts $OPTARG";;
\?) # invalid option \?) # invalid option
echo "Error: Invalid option here" echo "Error: Invalid option here"
exit;; exit;;
@ -76,6 +80,6 @@ if [ -d .git ] ; then
else else
echo "cloning..." echo "cloning..."
clone_dst='.' 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 fi