Break out git_fetch and only pull when there is a remote.
authorW. Trevor King <wking@drexel.edu>
Thu, 1 Dec 2011 18:28:28 +0000 (13:28 -0500)
committerW. Trevor King <wking@drexel.edu>
Thu, 1 Dec 2011 18:28:28 +0000 (13:28 -0500)
dotfiles.sh

index 7386fc4b7b38519f1a711a065cb15cab860b7e57..63d0adecc08a5913e387f0e43785cebb60136265 100755 (executable)
@@ -163,6 +163,17 @@ function get_repo_source()
        fi
 }
 
+function git_fetch()
+{
+       REPO=$(nonempty_option 'git_fetch' 'REPO' "${1}") || return 1
+       REMOTES=$(cd "${REPO}" && "${GIT}" remote) || return 1
+       if [ -n "${REMOTES}" ]; then
+               (cd "${REPO}" && "${GIT}" pull) || return 1
+       else
+               echo "no remote repositories found for ${REPO}"
+       fi
+}
+
 function wget_fetch()
 {
        REPO=$(nonempty_option 'wget_fetch' 'REPO' "${1}") || return 1
@@ -202,6 +213,7 @@ function wget_fetch()
        fi
 }
 
+
 # usage: link_file REPO FILE
 #
 # Create the symbolic link to the version of FILE in the REPO
@@ -336,7 +348,7 @@ function fetch()
                TRANSFER='git'
        fi
        if [ "${TRANSFER}" = 'git' ]; then
-               (cd "${REPO}" && "${GIT}" pull) || return 1
+               git_fetch "${REPO}" || return 1
        elif [ "${TRANSFER}" = 'wget' ]; then
                wget_fetch "${REPO}" || return 1
        else