From ade8df80b3a22e58d6f506a0647b2885c07dda9f Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Wed, 7 Sep 2016 22:10:03 +0100 Subject: [PATCH] _git_conn_check, call logger only at first failure --- etc/profile.d/git.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/etc/profile.d/git.sh b/etc/profile.d/git.sh index f6f8f162..cc933de8 100644 --- a/etc/profile.d/git.sh +++ b/etc/profile.d/git.sh @@ -122,7 +122,7 @@ git_list() { ssh $repo list | perl -ne '/(\S+).git/ and print "$1\n"' } -_git_conn_check=" " +_git_conn_check="" git_conn_check() { #local dest=$(git config --local --get remote.origin.url | sed -e 's/:.*$//' -e 's/^.*@//') local dest=$(git config --local --get remote.origin.url) @@ -146,16 +146,16 @@ git_conn_check() { *"@"*) timeout 5 ssh -o BatchMode=yes -o ConnectTimeout=5 $dest true && ok=1 ;; *) nc -z -w 5 $dest && ok=1 ;; esac -#echo "$ok: git=$(git config --local --get remote.origin.url) | dest=$dest | url2nc="$(url2nc $(git config --local --get remote.origin.url)) + [ -z "$_git_conn_check" ] && _git_conn_check=" " _git_conn_check="${_git_conn_check}$dest=$ok " + + if [ "$ok" != "1" ]; then + logger -t $NAME -s "Can't connect to $dest" + return 1 + fi + ;; esac - #if ! timeout 5 ssh BatchMode=yes -o ConnectTimeout=5 $dest true; then - if [ "$ok" != "1" ]; then - logger -t $NAME -s "Can't connect to $dest" - return 1 - fi - return 0 } -- 2.47.3