diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2012-05-04 21:25:01 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2012-05-04 21:25:01 +0200 |
commit | 0897d4baab634674348e5be3b2b7d9c4395e0548 (patch) | |
tree | f1bfd5b73f24f52d2bdd715325bbc6595a783819 /bashrc | |
parent | 520dcb9f6dba95066296de9f71e398cc30b84f69 (diff) | |
download | dotfiles-0897d4baab634674348e5be3b2b7d9c4395e0548.tar.gz dotfiles-0897d4baab634674348e5be3b2b7d9c4395e0548.tar.xz dotfiles-0897d4baab634674348e5be3b2b7d9c4395e0548.zip |
bashrc/main: timeout git fetch origin after 5s
Diffstat (limited to 'bashrc')
-rw-r--r-- | bashrc/main.sh | 16 |
1 files changed, 15 insertions, 1 deletions
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; |