From 0897d4baab634674348e5be3b2b7d9c4395e0548 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 4 May 2012 21:25:01 +0200 Subject: bashrc/main: timeout git fetch origin after 5s --- bashrc/main.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'bashrc') diff --git a/bashrc/main.sh b/bashrc/main.sh index e8e45ed..47c8d65 100644 --- a/bashrc/main.sh +++ b/bashrc/main.sh @@ -13,7 +13,21 @@ cd "${HOME}" _self_update() { pushd ${_DOTFILES_DIR} &>/dev/null - git fetch origin 2>/dev/null + # save the origin, the current master is based of + if ! git branch | grep old-origin -q; then + git branch old-origin origin/master + fi + + if hash timeout >/dev/null 2>&1; then + timeout 5s git fetch origin 2>/dev/null + if [[ "$?" == "124" ]]; then + echo -e "\033[31m*\033[0m timeout: git fetch origin" + return + fi + else + git fetch origin 2>/dev/null + fi + if [[ -n "$(git whatchanged HEAD..origin/master)" ]]; then echo -ne "\033[31m*\033[0m dotfile updates found, merge now? (Y/n) " read _merge; -- cgit v1.2.3