]> git.nbdom.net Git - nb.git/commitdiff
_git_conn_check, call logger only at first failure
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 7 Sep 2016 21:10:03 +0000 (22:10 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 7 Sep 2016 21:10:03 +0000 (22:10 +0100)
etc/profile.d/git.sh

index f6f8f16274e0b72fc2660ec4e31835dc8eb8d709..cc933de896a17401cd326c2068b0d0c4d4ef1519 100644 (file)
@@ -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
 }